QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:mdm
:TFLNO:050
:SCPAC:bc
:SCMOD:sbp
:SFLNO:004
:ICOD:D
:QURY:START
	 if s.ntsk  =  bcsbp004.ntsk then   
 	 |  *  The general task can be registered multiple times in BaanIV. The   
 	 |  *  user must be able to link several old tasks to one new task.   
 	  	 continue   
 	 endif   
 	 s.ntsk  =  bcsbp004.ntsk   
 	 var.bpmdm050.chlt  =  empty()   
 	 on case bcsbp004.orig   
 	 case bcsbp.orig.ti:   
 	  	 read.relevant.tirou003.data()   
 	  	 dump 1   
 	  	 break   
 	 case bcsbp.orig.tp:   
 	  	 read.relevant.tphrs010.data()   
 	  	 dump 2   
 	  	 break   
 	 default:   
 	  	 break   
 	 endcase
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:mdm
:TFLNO:050
:SCPAC:bc
:SCMOD:sbp
:SFLNO:004
:ICOD:S
:QURY:START
select 	 bcsbp004.*     
from 	 bcsbp004
order by bcsbp004._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:mdm
:TFLNO:050
:SCPAC:bc
:SCMOD:sbp
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:mdm
:TFLNO:055
:SCPAC:tp
:SCMOD:hrs
:SFLNO:010
:ICOD:D
:QURY:START
	 if tphrs010.dspl  =  tphrs.splt.finance then   
 	  	 var.bpmdm055.potf  =  tcyesno.yes   
 	 else   
 	  	 var.bpmdm055.potf  =  tcyesno.no   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:mdm
:TFLNO:055
:SCPAC:tp
:SCMOD:hrs
:SFLNO:010
:ICOD:S
:QURY:START
select 	 tphrs010.wgco, tphrs010.desc, tphrs010.dspl   
from 	 tphrs010
where 	 tphrs010.wgct  =  tppdm.wgct.amount   
 and 	 (tphrs010.dspl  =  tphrs.splt.no or   
 	 tphrs010.dspl  =  tphrs.splt.finance)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:mdm
:TFLNO:055
:SCPAC:tp
:SCMOD:hrs
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:tmm
:TFLNO:100
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:ti
:SCMOD:hra
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:bp
:TCMOD:tmm
:TFLNO:200
:SCPAC:tp
:SCMOD:hrs
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:D
:QURY:START
	  if tcmcs042.reto  =  tcyesno.no then   
 	   	  read.transaction.type.data(   
 	   	   	   	   	  tcmcs042.ttyp,   
 	   	   	   	   	  var.cisli001.sott,   
 	   	   	   	   	  g.negative.amounts.allowed)   
 	   	  if var.cisli001.sott  =  empty.string(1;3) then   
 	   	   	  var.cisli001.sosr  =  0   
 	   	  else   
 	   	   	  var.cisli001.sosr  =  tcmcs042.seri   
 	   	  endif   
 	  else   
 	   	  read.transaction.type.data(   
 	   	   	   	   	  tcmcs042.ttyp,   
 	   	   	   	   	  var.cisli001.cntt,   
 	   	   	   	   	  g.negative.amounts.allowed)   
 	   	  if var.cisli001.cntt  =  empty.string(1;3) then   
 	   	   	  var.cisli001.cnsr  =  0   
 	   	  else   
 	   	   	  var.cisli001.cnsr  =  tcmcs042.seri   
 	   	  endif   
 	  endif   
 	  if var.cisli001.sott  <>  "" and   
 	  var.cisli001.cntt  <>  "" then   
 	   	  break   
 	  endif   
 |  	  call.tfgld011()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:000
: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   
 	   	   	  read.transaction.type.data(   
 	   	   	   	   	  tfgld011.ttyp,   
 	   	   	   	   	  var.cisli001.sott,   
 	   	   	   	   	  g.negative.amounts.allowed)   
 	   	   	  if var.cisli001.sott  =  empty.string(1;3)then   
 	   	   	   	  var.cisli001.sosr  =  0   
 	   	   	  else   
 	   	   	   	  var.cisli001.sosr  =  tfgld011.dsrn   
 	   	   	  endif   
 	   	  else   
 	   	   	  read.transaction.type.data(   
 	   	   	   	   	  tfgld011.ttyp,   
 	   	   	   	   	  var.cisli001.cntt,   
 	   	   	   	   	  g.negative.amounts.allowed)   
 	   	   	  if var.cisli001.cntt  =  empty.string(1;3)then   
 	   	   	   	  var.cisli001.cnsr  =  0   
 	   	   	  else   
 	   	   	   	  var.cisli001.cnsr  =  tfgld011.dsrn   
 	   	   	  endif   
 	   	  endif   
 	   	  if var.cisli001.sott  <>  "" and   
 	   	  var.cisli001.cntt  <>  "" then   
 	   	   	  break   
 	   	  endif   
 	  endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:000
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:042
:ICOD:X
:QURY:START
|   *  Handle filling of cisli000   
 var.cisli000.indt  =  date.actual.set   
 var.cisli000.dsca  =  description.actual.set   
 dump 1   
 var.cisli000.indt  =  current.date   
 var.cisli000.dsca  =  description.current.date   
 dump 1   
 |   *  Handle filling of cisli001   
 |   *  Sales Order   
 insert.parameters.by.source.type(   
 	   	   	   	   	  date.actual.set,   
 	   	   	   	   	  current.date,   
 	   	   	   	   	  var.cisli001.sfcp,   
 	   	   	   	   	  40,  	  |   *  Sales Order   
 	   	   	   	   	  description.actual.set,   
 	   	   	   	   	  description.current.date,   
 	   	   	   	   	  var.cisli001.sott,   
 	   	   	   	   	  var.cisli001.sosr,   
 	   	   	   	   	  var.cisli001.cntt,   
 	   	   	   	   	  var.cisli001.cnsr)   
 if var.cisli001.rett  <>  "" then   
 	  |   *  Rebate   
 	  insert.parameters.by.source.type(   
 	   	   	   	   	  date.actual.set,   
 	   	   	   	   	  current.date,   
 	   	   	   	   	  var.cisli001.sfcp,   
 	   	   	   	   	  110,  	  |   *  Rebate   
 	   	   	   	   	  description.actual.set,   
 	   	   	   	   	  description.current.date,   
 	   	   	   	   	  "",  	  |   *  TransactionType   
 	   	   	   	   	  0,  	  |   *  Series   
 	   	   	   	   	  var.cisli001.rett,   
 	   	   	   	   	  var.cisli001.resr)   
 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:120
:SCPAC:bc
:SCMOD:sci
:SFLNO:000
:ICOD:D
:QURY:START
	  var.cisli120.brad  =  bcsci000.dpad   
 	  var.cisli120.dsca  =  form.text$("bcsci00002")   
 	  var.cisli120.seak  =  strip$(toupper$(var.cisli120.dsca))   
 	  dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:120
:SCPAC:bc
:SCMOD:sci
:SFLNO:000
:ICOD:S
:QURY:START
select  	  bcsci000.dpad   
from 	  bcsci000
where 	  bcsci000._index1  =  {1}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:120
:SCPAC:bc
:SCMOD:sci
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:120
:SCPAC:bc
:SCMOD:sci
:SFLNO:001
:ICOD:D
:QURY:START
	  br.addition.long  =  lval(var.cisli120.brad)  +  1   
 	  var.cisli120.brad  =  str$(br.addition.long)   
 	  get.description()   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:120
:SCPAC:bc
:SCMOD:sci
:SFLNO:001
:ICOD:S
:QURY:START
select  	  bcsci001.*     
from 	  bcsci001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:120
:SCPAC:bc
:SCMOD:sci
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:125
:SCPAC:bc
:SCMOD:sci
:SFLNO:000
:ICOD:D
:QURY:START
	  var.cisli125.scmp  =  get.compnr()   
 	  var.cisli125.brtp  =  bcsci000.dptp   
 	  var.cisli125.dsca  =  form.text$("bcsci00001")   
 	  var.cisli125.seak  =  strip$(toupper$(var.cisli125.dsca))   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:125
:SCPAC:bc
:SCMOD:sci
:SFLNO:000
:ICOD:S
:QURY:START
select  	  bcsci000.dptp   
from 	  bcsci000
where 	  bcsci000._index1  =  {1}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:125
:SCPAC:bc
:SCMOD:sci
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:D
:QURY:START
	  |   *  Initialize Global Variable   
 	  initialize.global.variables()   
 	  |   *  All rebates which are posted are selected, group by invoice.   
 	  if not bcint.dll0007.invoice.is.posted(   
 	   	   	   	   	  tdcms050.crtt,   
 	   	   	   	   	  tdcms050.crin) then   
 	   	  continue   
 	  endif   
 	  handle.migration.of.rebate.invoice(   
 	   	   	   	   	  tdcms050.crtt,   
 	   	   	   	   	  tdcms050.crin)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:S
:QURY:START
select  	  tdcms050.crtt,   
 	  tdcms050.crin   
from 	  tdcms050
where 	  tdcms050.type  =  tdcms.type.rebate   
 and  	  tdcms050.crin  <>  0   
 and  	  tdcms050.crtt  <>  ""   
 and  	  tdcms050.cmst  =  tdcms.cmst.closed
group by tdcms050.crtt, tdcms050.crin
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:td
:SCMOD:cms
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:D
:QURY:START
	  |   *  All deliveries which are atleast printed are selected, grouped by   
 	  |   *  invoices.   
 	     
 	  |   *  Initialize Global Variable   
 	  initialize.global.variables()   
 	  |   *  Skip not posted invoices.   
 	  if not bcint.dll0007.invoice.is.posted(   
 	   	   	   	   	  tdsls045.ttyp,   
 	   	   	   	   	  tdsls045.invn) then   
 	   	  continue   
 	  endif  	     
 	  handle.migration.of.sales.invoice(   
 	   	   	  tdsls045.ttyp,   
 	   	   	  tdsls045.invn)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:S
:QURY:START
select  	  tdsls045.ttyp,   
 	  tdsls045.invn   
from 	  tdsls045
where 	  tdsls045.ttyp  <>  ""   
 and  	  tdsls045.invn  <>  0
group by tdsls045.ttyp, tdsls045.invn
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:400
:ICOD:D
:QURY:START
	  |   *  Initialize Global Variable   
 	  initialize.global.variables()   
 	  handle.migration.of.manual.sales.invoice(   
 	   	   	   	   	  get.compnr(),   
 	   	   	   	   	  tfacr400.ttyp,   
 	   	   	   	   	  tfacr400.ninv)   
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:510
:ICOD:D
:QURY:START
	  |   *  Initialize Global Variable   
 	  initialize.global.variables()   
 	  handle.migration.of.interest.invoice(   
 	   	   	   	   	  get.compnr(),   
 	   	   	   	   	  tfacr510.ityp,   
 	   	   	   	   	  tfacr510.idoc,   
 	   	   	   	   	  tfacr510.cuno )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:510
:ICOD:S
:QURY:START
select  	  tfacr510.cuno,   
 	  tfacr510.ityp,   
 	  tfacr510.idoc   
from 	  tfacr510
group by tfacr510.cuno, tfacr510.ityp, tfacr510.idoc
order by tfacr510.cuno, tfacr510.ityp, tfacr510.idoc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tp
:SCMOD:pin
:SFLNO:100
:ICOD:D
:QURY:START
	  |   *  Initialize Global Variable   
 	  initialize.global.variables()   
 	  get.project.invoice.transaction.type(   
 	   	   	   	   	  (tppin100.amoi  -  tppin100.amdi  -     
 	   	   	   	   	  tppin100.amdl  +  tppin100.csqz),   
 	   	   	   	   	  g.project.transaction.type)   
 	  if not bcint.dll0007.invoice.is.posted(   
 	   	   	   	   	  g.project.transaction.type,   
 	   	   	   	   	  tppin100.ninv) then   
 	   	  continue   
 	  endif  	     
 	  handle.migration.of.project.invoice(   
 	   	   	   	   	  g.project.transaction.type,   
 	   	   	   	   	  tppin100.ninv)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tp
:SCMOD:pin
:SFLNO:100
:ICOD:S
:QURY:START
select  	  tppin100.*  ,tppdm600.pcba   
from 	  tppin100, tppdm600
where 	  tppin100._index1  =  {  	  tppdm.stin.final }   
 and  	  tppin100.cfpo  =    	  tppdm.yeno.yes   
 and  	  tppin100.post  =    	  tppdm.yeno.yes   
 and  	  tppdm600._index1  =  {  	  tppin100.cprj}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:tp
:SCMOD:pin
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:D
:QURY:START
	  |   *  Initialize  	  Global Variable  	     
 	  initialize.global.variables()   
 	  |   *  Skip not posted invoices.  	     
 	  if not bcint.dll0007.invoice.is.posted(   
 	   	   	   	   	  tssma611.ttyp,   
 	   	   	   	   	  tssma611.invn) then   
 	   	  continue   
 	  endif   
 	  if tssma611.titr  =  tssma.titr.serviceorder then   
 	   	  handle.migration.of.service.invoice(  	     
 	   	   	   	  tssma611.ncmp,   
 	   	   	   	  tssma611.ttyp,   
 	   	   	   	  tssma611.invn)   
 	  else   
 	   	  handle.migration.of.service.contract.invoice(  	     
 	   	   	   	  tssma611.ncmp,   
 	   	   	   	  tssma611.ttyp,   
 	   	   	   	  tssma611.invn)   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:F
:QURY:START
	  generate.contract.line(   
 	   	   	   	   	  true,  	  |   *  Initialize   
 	   	   	   	   	  "",  	  |   *  Contract   
 	   	   	   	   	  g.dummy.long) |   *  Sequence
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:S
:QURY:START
select  	   	  tssma611.ncmp, tssma611.ttyp, tssma611.invn, tssma611.titr   
from 	   	  tssma611
where 	   	  tssma611.ista  >  tssma.ista.checked
group by 	  tssma611.ncmp, tssma611.ttyp, tssma611.invn, tssma611.titr
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ci
:TCMOD:sli
:TFLNO:305
:SCPAC:ts
:SCMOD:sma
:SFLNO:611
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rpd
:TFLNO:320
:SCPAC:ti
:SCMOD:mps
:SFLNO:220
:ICOD:D
:QURY:START
	 select tiitm001.cwar:var.cprpd320.cwar  
 	 from 	 tiitm001  
 	 where tiitm001._index1 =  {:timps220.plni}  
 	 as set with 1 rows  
 	 selectdo  
 	 selectempty  
 	 	 var.cprpd320.cwar =  bcscp000.cwar  
 	 endselect  
 	 | *  Fill expiry date when it's empty.  
 	 if timps220.exdt =  0 then  
 	 	 timps220.exdt =  max.date  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rpd
:TFLNO:320
:SCPAC:ti
:SCMOD:mps
:SFLNO:220
:ICOD:S
:QURY:START
select 	 timps220.*
from 	 timps220
where 	 timps220._index1 =  {:act.plnc}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rpd
:TFLNO:320
:SCPAC:ti
:SCMOD:mps
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rpd
:TFLNO:330
:SCPAC:ti
:SCMOD:mps
:SFLNO:230
:ICOD:D
:QURY:START
	 if timps230.exdt =  0 then  
 	 	 timps230.exdt =  max.date  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rpd
:TFLNO:330
:SCPAC:ti
:SCMOD:mps
:SFLNO:230
:ICOD:S
:QURY:START
select 	 timps230.*
from 	 timps230
where 	 timps230._index1 =  {:act.plnc}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rpd
:TFLNO:330
:SCPAC:ti
:SCMOD:mps
:SFLNO:230
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:cp
:SCMOD:rmp
:SFLNO:140
:ICOD:D
:QURY:START
	  dump.for.cprmp140()   
 	  |# The logic for this part has been put into a function, because   
 	  |# otherwise the main query will be too long which will   
 	  |# give problems while trying to debug.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(tdinv150.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.kotr  =  convert.tckotr(tdinv150.kotr)   
 	  var.cprrp010.pono  =  get.inv150.position.number(tdinv150.cprj, tdinv150.orno)   
 	  var.cprrp010.date  =  tdinv150.date   
 	  var.cprrp010.time  =  get.time(  	  tdinv150.kotr)   
 	  var.cprrp010.qana  =  tdinv150.qana   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:310
:ICOD:D
:QURY:START
	  dump.for.timps310()   
 	  |# The logic for this part has been put into a function, because   
 	  |# otherwise the main query will be too long which will   
 	  |# give problems while trying to debug.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:510
:ICOD:D
:QURY:START
	  dump.for.timps510()   
 	  |# The logic for this part has been put into a function, because   
 	  |# otherwise the main query will be too long which will   
 	  |# give problems while trying to debug.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:520
:ICOD:D
:QURY:START
	  dump.for.timps520()   
 	  |# The logic for this part has been put into a function, because   
 	  |# otherwise the main query will be too long which will   
 	  |# give problems while trying to debug.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:cp
:TCMOD:rrp
:TFLNO:100
:SCPAC:ti
:SCMOD:mps
:SFLNO:530
:ICOD:D
:QURY:START
	  dump.for.timps530()   
 	  |# The logic for this part has been put into a function, because   
 	  |# otherwise the main query will be too long which will   
 	  |# give problems while trying to debug.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(timrp010.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.resi  =  var.curr.site   
 	  var.cprrp010.pono  =  base.position   
 	  var.cprrp010.kotr  =  convert.tckotr(timrp010.kotr)   
 	  var.cprrp010.date  =  timrp010.date   
 	  var.cprrp010.time  =  get.time(timrp010.kotr)   
 	  var.cprrp010.qana  =  timrp010.qana   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(timrp020.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.plnc  =  var.cprrp100.plnc   
 	  var.cprrp010.resi  =  var.curr.site   
 	  var.cprrp010.koor  =  var.cprrp100.type   
 	  var.cprrp010.orno  =  var.cprrp100.orno   
 	  var.cprrp010.pono  =  0   
 	  var.cprrp010.kotr  =  convert.tckotr(tckotr.receipt)   
 	  var.cprrp010.time  =  get.time(tckotr.receipt)   
 	  var.cprrp010.qana  =  timrp020.oqan   
 	  var.cprrp100.item  =  cp.segment.item.code(timrp020.item, itm.cprj, itm.clus)   
 	  var.cprrp100.plmt  =  get.plmt(timrp020.cpla, timrp020.plnm)   
 	  if timrp020.fsdt  =  0 or timrp020.ffdt  =  0 then   
 	   	  var.cprrp100.psdt  =  timrp020.psdt   
 	   	  var.cprrp100.pfdt  =  timrp020.pfdt   
 	  else   
 	   	  var.cprrp100.psdt  =  timrp020.fsdt   
 	   	  var.cprrp100.pfdt  =  timrp020.ffdt   
 	  endif   
 	  var.cprrp010.date  =  var.cprrp100.pfdt   
 	  var.cprrp100.trdt  =  timrp020.trdt   
 	  var.cprrp100.pstm  =  get.time(tckotr.requirement)   
 	  var.cprrp100.pftm  =  get.time(tckotr.receipt)   
 	  var.cprrp100.oqan  =  timrp020.oqan   
 	  var.cprrp100.cplb  =  timrp020.cplb   
 	  var.cprrp100.osta  =  get.mrp.osta(timrp020.osta)   
 	  var.cprrp100.dwar  =  timrp020.cwar   
 	  var.cprrp100.opro  =  timrp020.opro   
 	  var.cprrp100.txta  =  empty()   
 	  dump 2  	  |   *  Planned Orders   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(timrp021.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.plnc  =  var.cprrp100.plnc   
 	  var.cprrp010.resi  =  var.curr.site   
 	  var.cprrp010.koor  =  var.cprrp100.type   
 	  var.cprrp010.orno  =  var.cprrp100.orno   
 	  var.cprrp010.pono  =  0   
 	  var.cprrp010.kotr  =  convert.tckotr(tckotr.receipt)   
 	  var.cprrp010.time  =  get.time(tckotr.receipt)   
 	  var.cprrp010.qana  =  timrp021.oqan   
 	  var.cprrp100.item  =  cp.segment.item.code(timrp021.item, itm.cprj, itm.clus)   
 	  var.cprrp100.plmt  =  get.plmt(timrp021.cpla, empty)   
 	  if timrp021.fodt  =  0 or timrp021.fddt  =  0 then   
 	   	  var.cprrp100.psdt  =  timrp021.podt   
 	   	  var.cprrp100.pfdt  =  timrp021.pddt   
 	  else   
 	   	  var.cprrp100.psdt  =  timrp021.fodt   
 	   	  var.cprrp100.pfdt  =  timrp021.fddt   
 	  endif   
 	  var.cprrp010.date  =  var.cprrp100.pfdt   
 	  var.cprrp100.trdt  =  timrp021.trdt   
 	  var.cprrp100.pstm  =  get.time(tckotr.requirement)   
 	  var.cprrp100.pftm  =  get.time(tckotr.receipt)   
 	  var.cprrp100.cplb  =  timrp021.cplb   
 	  var.cprrp100.osta  =  get.mrp.osta(timrp021.osta)   
 	  var.cprrp100.dwar  =  timrp021.cwar   
 	  var.cprrp100.oqan  =  timrp021.oqan   
 	  var.cprrp100.suno  =  get.business.partner.code(timrp021.suno, bcstc.orgn.suno, err.mess)   
 	  var.cprrp100.txta  =  empty()   
 	  dump 3  	  |   *  Planned Orders   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(timrp022.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.plnc  =  var.cprrp100.plnc   
 	  var.cprrp010.resi  =  var.curr.site   
 	  var.cprrp010.koor  =  var.cprrp100.type   
 	  var.cprrp010.orno  =  var.cprrp100.orno   
 	  var.cprrp010.pono  =  0   
 	  var.cprrp010.kotr  =  convert.tckotr(tckotr.receipt)   
 	  var.cprrp010.time  =  get.time(tckotr.receipt)   
 	  var.cprrp010.qana  =  timrp022.oqan   
 	  var.cprrp100.item  =  cp.segment.item.code(timrp022.item, itm.cprj, itm.clus)   
 	  var.cprrp100.plmt  =  get.plmt(timrp022.cpla, empty)   
 	  if timrp022.fsdt  =  0 or timrp022.ffdt  =  0 then   
 	   	  var.cprrp100.psdt  =  timrp022.psdt   
 	   	  var.cprrp100.pfdt  =  timrp022.pfdt   
 	  else   
 	   	  var.cprrp100.psdt  =  timrp022.fsdt   
 	   	  var.cprrp100.pfdt  =  timrp022.ffdt   
 	  endif   
 	  var.cprrp010.date  =  var.cprrp100.pfdt   
 	  var.cprrp100.trdt  =  timrp022.trdt   
 	  var.cprrp100.pstm  =  get.time(tckotr.requirement)   
 	  var.cprrp100.pftm  =  get.time(tckotr.receipt)   
 	  var.cprrp100.cplb  =  timrp022.cplb   
 	  var.cprrp100.osta  =  get.mrp.osta(timrp022.osta)   
 	  var.cprrp100.dwar  =  timrp022.cwar   
 	  var.cprrp100.oqan  =  timrp022.oqan   
 	  var.cprrp100.opro  =  timrp022.opro   
 	  var.cprrp100.txta  =  empty()   
 	  dump 2  	  |   *  Planned Orders   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(trdrp015.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.plnc  =  act.plnc   
 	  var.cprrp010.resi  =  var.curr.site   
 	  var.cprrp010.pono  =  10   
 	  var.cprrp010.kotr  =  convert.tckotr(trdrp015.kotr)   
 	  var.cprrp010.date  =  trdrp015.date   
 	  var.cprrp010.time  =  get.time(  	  trdrp015.kotr)   
 	  var.cprrp010.qana  =  trdrp015.qana   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.cprrp010.plni   =  cp.segment.item.code(trdrp020.item, itm.cprj, bcscp003.clus) |# FP9.n   
 	  endif   
 	  var.cprrp010.plnc  =  var.cprrp100.plnc   
 	  var.cprrp010.resi  =  var.curr.site   
 	  var.cprrp010.koor  =  var.cprrp100.type   
 	  var.cprrp010.orno  =  var.cprrp100.orno   
 	  var.cprrp010.pono  =  0   
 	  var.cprrp010.kotr  =  convert.tckotr(tckotr.receipt)   
 	  var.cprrp010.date  =  trdrp020.prdt   
 	  var.cprrp010.time  =  get.time(tckotr.receipt)   
 	  var.cprrp010.qana  =  trdrp020.oqua   
 	  var.cprrp100.item  =  cp.segment.item.code(trdrp020.item, itm.cprj, itm.clus)   
 	  var.cprrp100.plmt  =  get.plmt(empty, empty)   
 	  var.cprrp100.psdt  =  trdrp020.podt   
 	  var.cprrp100.pfdt  =  trdrp020.prdt   
 	  var.cprrp100.trdt  =  date.num()   
 	  var.cprrp100.pstm  =  get.time(tckotr.requirement)   
 	  var.cprrp100.pftm  =  get.time(tckotr.receipt)   
 	  var.cprrp100.cplb  =  tiitm001.cplb   
 	  var.cprrp100.osta  =  get.mrp.osta(trdrp020.orsa)   
 	  var.cprrp100.dwar  =  trdrp020.dwar   
 	  var.cprrp100.supl  =  cp.segment.item.code(trdrp020.item, itm.cprj, sup.clus)   
 	  var.cprrp100.suwa  =  trdrp020.rwar   
 	  var.cprrp100.oqan  =  trdrp020.oqua   
 	  dump 1  	  |   *  Planned Orders   
 	  dump 5  	  |   *  Inventory Movements
:QURY:END
:TEXT:

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:fm
:TCMOD:foc
:TFLNO:200
:SCPAC:tr
:SCMOD:toc
:SFLNO:101
:ICOD:D
:QURY:START
	  if trtoc101.itty  =  trtoc.itty.standard then   
 	    	  var.fmfoc201.item  =  segment.item.code(trtoc101.item, "")   
 	    	  select  	  tiitm001.cuni:inventory.unit,   
 	    	    	  tiitm001.kitm:item.type,   
 	    	    	  tiitm001.itmt:item.type.project   
 	    	  from  	  tiitm001   
 	    	  where  	  tiitm001._index1  =  {:trtoc101.item}   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	  endselect   
 	    	  if item.type.project  =  tppdm.itmt.equipment or   
 	    	  item.type.project  =  tppdm.itmt.subcontracting or   
 	    	  (item.type  <>  tckitm.purchase and   
 	    	  item.type  <>  tckitm.manufacture) then   
 	    	    	  continue   
 	    	  endif   
 	  else   
 	    	  var.fmfoc201.item  =  segment.item.code(trtoc101.item, get.project(trtoc101.cprj))   
 	    	  select  	  tipcs021.cuni:inventory.unit   
 	    	  from  	  tipcs021   
 	    	  where  	  tipcs021._index1  =  {:trtoc101.cprj, :trtoc101.item}   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	  endselect   
 	  endif   
 	  if convert.transport.order.number(   
 	    	  trtoc101.orno,   
 	    	  trtoc101.pono,   
 	    	  o.mess) then   
 	    	  continue   
 	  else   
 	    	  var.fmfoc200.orno  =  bcsfm001.norn   
 	  endif   
 	  if not get.enterprise.unit( trtoc101.ncmp, log.company, o.mess) then   
 	    	  var.fmfoc200.sofc  =  bcstc018.shod   
 	    	  var.fmfoc200.sfad  =  trtoc101.clad   
 	    	  var.fmfoc200.stad  =  trtoc101.cuad   
 	    	  get.shipping.data(  	  trtoc101.toor,   
 	    	    	    	    	  trtoc101.oror,   
 	    	    	    	    	  trtoc101.orpo,   
 	    	    	    	    	  trtoc101.orse,   
 	    	    	    	    	  var.fmfoc200.sfty,   
 	    	    	    	    	  var.fmfoc200.sfco,   
 	    	    	    	    	  var.fmfoc200.sfad,   
 	    	    	    	    	  var.fmfoc200.stty,   
 	    	    	    	    	  var.fmfoc200.stco,   
 	    	    	    	    	  var.fmfoc200.stad)   
 	    	  var.fmfoc201.orwh  =  ""   
 	    	  if var.fmfoc200.sfty  =  1 then   
 	    	    	  var.fmfoc201.orwh  =  var.fmfoc200.sfco   
 	    	  endif   
 	    	  on case trtoc101.toor   
 	    	  case trtoc.toor.sales:   
 	    	  case trtoc.toor.sales.delivery:   
 	    	    	  var.fmfoc201.coof  =  bcstc018.lcmp   
 	    	    	  var.fmfoc201.oofc  =  bcstc018.sofd   
 	    	    	  var.fmfoc201.orsq  =  get.sls.order.line.sequence.number(   
 	    	    	    	    	    	  trtoc101.oror,   
 	    	    	    	    	    	  trtoc101.orpo,   
 	    	    	    	    	    	  trtoc101.orse)   
 	    	    	  break   
 	    	  case trtoc.toor.pur.planned:   
 	    	    	  var.fmfoc201.coof  =  bcstc018.lcmp   
 	    	    	  var.fmfoc201.oofc  =  bcstc018.pofd   
 	    	    	  var.fmfoc201.orsq  =  get.pur.order.line.sequence.number(   
 	    	    	    	    	    	  trtoc101.orse)   
 	    	    	  break   
 	    	  default:   
 	    	    	  var.fmfoc201.coof  =  empty()   
 	    	    	  var.fmfoc201.oofc  =  empty()   
 	    	    	  var.fmfoc201.orsq  =  trtoc101.orse   
 	    	    	  break   
 	    	  endcase   
 	    	  var.fmfoc201.lref  =  str$(trtoc101.orno)  &  " / "  &  str$(trtoc101.pono)   
 	    	  var.fmfoc201.cplg  =  ""   
 	    	  find.plangroup(trtoc101.cmtg, trtoc101.trat, var.fmfoc201.cplg)   
 	    	  if trtoc100.fryn  =  tcyesno.yes or trtoc101.fryn  =  tcyesno.yes then   
 	    	    	  var.fmfoc201.sgsh  =  tcyesno.yes   
 	    	  else   
 	    	    	  var.fmfoc201.sgsh  =  tcyesno.no   
 	    	  endif   
 	    	  dump 1   
 	    	  if trtoc000.htoc  =  tcyesno.yes then   
 	    	    	  dump 3   
 	    	  endif   
 	    	  conv.factor  =  1.0   
 	    	  if trtoc101.paun  <>  inventory.unit then   
 	    	    	  conv.factor  =  tiitm.dll0003.conv.factor(   
 	    	    	    	  trtoc101.cprj,   
 	    	    	    	  trtoc101.item,   
 	    	    	    	  "",   
 	    	    	    	  "",   
 	    	    	    	  trtoc101.paun)   
 	    	  endif   
 	    	  var.fmfoc201.qstk  =  trtoc101.paqu  *  conv.factor   
 	    	  conv.factor  =  1.0   
 	    	  conv.factor2  =  1.0   
 	    	  if trtoc101.maun  <>  trtcd000.cuma then   
 	    	    	  conv.factor  =  tiitm.dll0003.read.conv.with.physical.quantity(   
 	    	    	    	  trtoc101.maun,   
 	    	    	    	  tctccu.mass)   
 	    	    	  conv.factor2  =  tiitm.dll0003.read.conv.with.physical.quantity(   
 	    	    	    	  trtcd000.cuma,   
 	    	    	    	  tctccu.mass)   
 	    	  endif   
 	    	  if conv.factor2  >  0 then   
 	    	    	  var.fmfoc201.wtdt  =  trtoc101.maqu  *  conv.factor  /  conv.factor2   
 	    	  else   
 	    	    	  var.fmfoc201.wtdt  =  0.0   
 	    	  endif   
 	    	  var.fmfoc201.adru  =  empty()   
 	    	  var.fmfoc201.adrq  =  empty()   
 	    	  if not isspace(trtoc101.raun) then   
 	    	    	  select  	  tcmcs001.tccu   
 	    	    	  from  	  tcmcs001   
 	    	    	  where  	  tcmcs001._index1  =  {:trtoc101.raun}   
 	    	    	  and  	  (tcmcs001.tccu  <>  tctccu.mass and   
 	    	    	    	  tcmcs001.tccu  <>  tctccu.time)   
 	    	    	  as set with 1 rows   
 	    	    	  selectdo   
 	    	    	    	  var.fmfoc201.adru  =  trtoc101.raun   
 	    	    	    	  var.fmfoc201.adrq  =  trtoc101.raqu   
 	    	    	  endselect   
 	    	  endif   
 	    	  dump 2   
 	    	  if trtoc000.htoc  =  tcyesno.yes then   
 	    	    	  var.fmfoc501.logn  =  isspace(trtoc100.logn)  ?  logname$:trtoc100.logn   
 	    	    	  dump 4   
 	    	  endif   
 	    	  dump 5   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:fm
:TCMOD:foc
:TFLNO:200
:SCPAC:tr
:SCMOD:toc
:SFLNO:101
:ICOD:S
:QURY:START
select  	  trtoc101.*  , trtoc100.*   
from 	  trtoc101, trtoc100
where 	  trtoc101.orno  >  0   
 and  	  trtoc100.orno  =  trtoc101.orno   
 and  	  trtoc101.refp  =  trtoc101.pono   
 and  	  (trtoc101.ostb  =  trtoc.ostb.free or   
 	  trtoc101.ostb  =  trtoc.ostb.dont.invoice or   
 	  trtoc101.ostb  =  trtoc.ostb.to.invoice)   
 and  	  (trtoc101.plst  =  trtoc.plst.dont.plan or   
 	  trtoc101.plst  =  trtoc.plst.to.plan)   
 and  	  trtoc101.itty  <>  trtoc.itty.others   
 and  	  (trtoc101.toor  =  trtoc.toor.sales or   
 	  trtoc101.toor  =  trtoc.toor.sales.delivery or   
 	  trtoc101.toor  =  trtoc.toor.pur.planned or   
 	  trtoc101.toor  =  trtoc.toor.rpl.planned or   
 	  trtoc101.toor  =  trtoc.toor.rpl.delivery)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:fm
:TCMOD:foc
:TFLNO:200
:SCPAC:tr
:SCMOD:toc
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:000
:SCPAC:tc
:SCMOD:qms
:SFLNO:000
:ICOD:S
:QURY:START
select tcqms000.*     
from tcqms000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:000
:SCPAC:tc
:SCMOD:qms
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:017
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:017
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:S
:QURY:START
select tiitm002.kitm, tiitm002.citg   
from tiitm002
where tiitm002._index1 inrange {tckitm.purchase} and   
 {tckitm.manufacture}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:017
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:018
:SCPAC:tc
:SCMOD:qms
:SFLNO:011
:ICOD:D
:QURY:START
	  if tcqms011.cprj  <>  hold.project or   
 	  tcqms011.item  <>  hold.item then   
 	    	  if item.present.in.quality.groups(   
 	    	    	    	  tcqms011.cprj,   
 	    	    	    	  tcqms011.item) then   
 	    	    	   |   *  Check if the project  /  item combination   
 	    	    	   |   *  is already dumped via tcqms020 table   
 	    	    	  continue   
 	    	  endif    
 	    	  hold.project  =  tcqms011.cprj   
 	    	  hold.item  =  tcqms011.item   
 	    	  var.qmptc018.qitg  =  tcqms011.qitg   
 	    	  var.qmptc018.item  =  segment.item.code(   
 	    	    	    	    	    	  tcqms011.item,   
 	    	    	    	    	    	  get.ti.project(tcqms011.cprj))   
 	    	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:018
:SCPAC:tc
:SCMOD:qms
:SFLNO:011
:ICOD:S
:QURY:START
select  	  tcqms011.item, tcqms011.cprj  
from 	  tcqms011
where 	  tcqms011.item  <>  ""
order by tcqms011.item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:018
:SCPAC:tc
:SCMOD:qms
:SFLNO:011
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:018
:SCPAC:tc
:SCMOD:qms
:SFLNO:020
:ICOD:D
:QURY:START
	  var.qmptc018.qitg  =  tcqms020.qitg   
 	  var.qmptc018.item  =  segment.item.code(tcqms020.item,get.ti.project(tcqms020.cprj))   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:018
:SCPAC:tc
:SCMOD:qms
:SFLNO:020
:ICOD:S
:QURY:START
select tcqms020.*   
from tcqms020
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:018
:SCPAC:tc
:SCMOD:qms
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:019
:SCPAC:tc
:SCMOD:qms
:SFLNO:011
:ICOD:D
:QURY:START
	 var.qmptc011.guid  =  "MIG_"  &  str$(count)   
 	 count  =  count  +  1   
 	    
 	 if (tcqms011.opol  =  tcittb.customized ) then   
 	  	 var.qmptc011.sitm  =  segment.item.code(tcqms011.sitm,get.ti.project(tcqms011.cprj) )   
 	 else   
 	  	 var.qmptc011.sitm  =  segment.item.code(tcqms011.sitm,empty.string(1;8))   
 	 endif   
 	 var.qmptc011.blmt  =  etol (tcqms011.blmt)   
 	    
 	 if ((var.qmptc011.blmt  =  5) or   
 	  (var.qmptc011.blmt  =  6)) then   
 	  	 var.qmptc011.blmt  =  4   
 	 endif   
 	    
 	 if isspace(tcqms011.cuno) then   
 	  	 get.business.partner(tcqms011.suno,bcstc.orgn.suno,o.errmesg)   
 	 else   
 	  	 get.business.partner(tcqms011.cuno,bcstc.orgn.cuno,o.errmesg)   
 	 endif   
 	    
 	 if tcqms011.orgn  =  tcqms.orgn.matl.bom then   
 	  	 if item  <>  tcqms011.item or   
 	   	  sub.item  <>  tcqms011.sitm then   
 	   	   	  item  =  tcqms011.item   
 	   	   	  sub.item  =  tcqms011.sitm   
 	   	   	  if tcqms011.pono  <>  0 then   
 	   	   	   	  tcqms011.pono  =  0   
 	   	   	  endif   
 	   	   	  dump 1   
 	  	 endif   
 	 else   
 	  	 dump 1   
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:019
:SCPAC:tc
:SCMOD:qms
:SFLNO:011
:ICOD:S
:QURY:START
select tcqms011.*     
from tcqms011
order by tcqms011._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:019
:SCPAC:tc
:SCMOD:qms
:SFLNO:011
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:029
:SCPAC:tc
:SCMOD:mcs
:SFLNO:029
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:029
:SCPAC:tc
:SCMOD:mcs
:SFLNO:029
:ICOD:S
:QURY:START
select tcmcs029.*    
from tcmcs029
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:029
:SCPAC:tc
:SCMOD:mcs
:SFLNO:029
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:049
:SCPAC:tc
:SCMOD:qms
:SFLNO:049
:ICOD:D
:QURY:START
on case tcqms049.orgn   
 	 case tcqms.orgn.sales:   
 	  	 var.qmptc049.orno  =  convert.number(bcckon.act.sls,tcqms049.orno)   
 	  	 break   
 	 case tcqms.orgn.purchase:   
 	  	 var.qmptc049.orno  =  convert.number(bcckon.act.pur,tcqms049.orno)   
 	  	 break   
 	 case tcqms.orgn.production:   
 	 case tcqms.orgn.matl.bom:   
 	 case tcqms.orgn.rou.ti:   
 	  	 var.qmptc049.orno  =  convert.number(bcckon.act.sfc,tcqms049.orno)   
 	  	 break   
 	 case tcqms.orgn.cwar.insp:   
 	 var.qmptc049.orno  =  empty.string(1;9)   
 	  	 break   
 	 endcase   
 	  	  	  	  	  	  	 | March 10 2004.en   
 	    
 if ((etol (tcqms049.blmt)  =  5) or (etol (tcqms049.blmt)  =  6)) then   
 	  	 var.qmptc049.blmt  =  4   
 	 else   
 	  	 var.qmptc049.blmt  =  etol (tcqms049.blmt)   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:049
:SCPAC:tc
:SCMOD:qms
:SFLNO:049
:ICOD:S
:QURY:START
select tcqms049.*    
from tcqms049   
 	  	 | March 10 2004.sn
where (tcqms049.orgn  <>  tcqms.orgn.process and   
 	 tcqms049.orgn  <>  tcqms.orgn.matl.frm and   
 	 tcqms049.orgn  <>  tcqms.orgn.rou.ps )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:049
:SCPAC:tc
:SCMOD:qms
:SFLNO:049
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:050
:SCPAC:tc
:SCMOD:qms
:SFLNO:050
:ICOD:D
:QURY:START
on case tcqms050.orgn   
 	  case tcqms.orgn.sales:   
 	   	  var.qmptc050.orno  =  convert.number(bcckon.act.sls,tcqms050.orno)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  var.qmptc050.orno  =  convert.number(bcckon.act.pur,tcqms050.orno)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc050.orno  =  convert.number(bcckon.act.sfc,tcqms050.orno)   
 	   	  break   
 	  case tcqms.orgn.cwar.insp:   
 	  var.qmptc050.orno  =  empty.string(1;9)   
 	   	  break   
 	  endcase   
 	   	   	   	   	   	   	  | March 10 2004.en   
 	  var.qmptc050.vrsn  =  1  	   	   	  | FP8.n   
 	  var.qmptc050.aqll  =  (100  -  tcqms050.pper)   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:050
:SCPAC:tc
:SCMOD:qms
:SFLNO:050
:ICOD:S
:QURY:START
select tcqms050.*    
from tcqms050   
 	   	  | March 10 2004.sn
where (tcqms050.orgn  <>  tcqms.orgn.process and   
 	  tcqms050.orgn  <>  tcqms.orgn.matl.frm and   
 	  tcqms050.orgn  <>  tcqms.orgn.rou.ps )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:050
:SCPAC:tc
:SCMOD:qms
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:051
:SCPAC:tc
:SCMOD:qms
:SFLNO:051
:ICOD:D
:QURY:START
	  on case tcqms051.orgn   
 	  case tcqms.orgn.sales:   
 	   	  var.qmptc051.orno  =  convert.number(bcckon.act.sls,tcqms051.orno)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  var.qmptc051.orno  =  convert.number(bcckon.act.pur,tcqms051.orno)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc051.orno  =  convert.number(bcckon.act.sfc,tcqms051.orno)   
 	   	  break   
 	  | case tcqms.orgn.cwar.insp:   
 	  | var.qmptc051.orno  =  convert.number(....,tcqms051.orno)   
 	  |  	  break   
 	  endcase   
 	   	   	   	   	   	   	  | March 10 2004.en   
 	  get.characteristic.option.for.QM(tcqms051.char, tcqms051.oset,o.errmess)   
 	  var.qmptc051.vaty  =  1  	   	   	   	   	  |# FP10.sn   
 	  if ((tcqms051.ctyp  =  tcqms.ctyp.fraction or  	   	     
 	  tcqms051.ctyp  =  tcqms.ctyp.integer) and   
 	  tcqms051.mthd  =  tcqms.mthd.fixed) or   
 	  tcqms051.ctyp  =  tcqms.ctyp.option then   
 	   	  var.qmptc051.vaty  =  3   
 	  endif  	   	   	   	   	   	   	  |# FP10.en  	     
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:051
:SCPAC:tc
:SCMOD:qms
:SFLNO:051
:ICOD:S
:QURY:START
select tcqms051.*     
from tcqms051   
 	  | March 10 2004.sn
where (tcqms051.orgn  <>  tcqms.orgn.process and   
 	  tcqms051.orgn  <>  tcqms.orgn.matl.frm and   
 	  tcqms051.orgn  <>  tcqms.orgn.rou.ps )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:051
:SCPAC:tc
:SCMOD:qms
:SFLNO:051
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:100
:SCPAC:tc
:SCMOD:qms
:SFLNO:120
:ICOD:D
:QURY:START
	  if tdilc000.iilc  =  tcyesno.yes then   
 	   	  ILC.IMPLEMENTED  =  1   
 	  else   
 	   	  ILC.IMPLEMENTED  =  0   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:100
:SCPAC:tc
:SCMOD:qms
:SFLNO:120
:ICOD:S
:QURY:START
select  	  tdilc000.*     
from 	  tdilc000   
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:100
:SCPAC:tc
:SCMOD:qms
:SFLNO:120
:ICOD:X
:QURY:START
select  	  tcqms120.*     
 from  	  tcqms120   
 where  	  (tcqms120.orgn  <>  tcqms.orgn.process and   
 	  tcqms120.orgn  <>  tcqms.orgn.matl.frm and   
 	  tcqms120.orgn  <>  tcqms.orgn.rou.ps)   
 order by tcqms120._index1   
 selectdo   
 	  var.qmptc120.rsta  =  tcqms120.rsta  	   	   	     
 	  on case tcqms120.orgn   
 	  case tcqms.orgn.sales:   
 	   	  order.line.ready.for.inspections  =  true   
 	   	  if ILC.IMPLEMENTED then   
 	   	   	  select  	  tdilc401.*     
 	   	   	  from  	  tdilc401   
 	   	   	  where  	  tdilc401._index1  =  {  	  tdilc.koob.act.sls,   
 	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	  and  	  tdilc401.proc  =  tcyesno.no   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	   	  order.line.ready.for.inspections  =  false   
 	   	   	  endselect   
 	   	  endif   
 	   	     
 	   	  if not order.line.ready.for.inspections then   
 	   	   	  continue   
 	   	  endif   
 	   	  var.qmptc120.orno  =  convert.number(  	  bcckon.act.sls,   
 	   	   	   	   	   	   	  tcqms120.orno)   
 	   	  var.qmptc120.seqn  =     
 	   	   	  get.sls.order.line.sequence.number(   
 	   	   	   	   	   	   	   	  tcqms120.orno,   
 	   	   	   	   	   	   	   	  tcqms120.pono,   
 	   	   	   	   	   	   	   	  tcqms120.srnb)   
 	   	  var.qmptc120.bpid  =  get.business.partner.code.for.QM(   
 	   	  tcqms120.orno,   
 	   	  bcstc.orgn.cuno,   
 	   	  o.errmess)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  order.line.ready.for.inspections  =  true   
 	   	  if ILC.IMPLEMENTED then   
 	   	   	  select tdilc402.*     
 	   	   	  from  	  tdilc402   
 	   	   	  where  	  tdilc402._index1  =  {  	  tdilc.kooa.act.pur,   
 	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	  and  	  tdilc402.astc  <>  0.0   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	   	  order.line.ready.for.inspections  =  true   
 	   	   	  selectempty   
 	   	   	   	  select  	  tdilc402.*     
 	   	   	   	  from  	  tdilc402   
 	   	   	   	  where  	  tdilc402._index1  =  {  	  tdilc.kooa.stock.transfer,   
 	   	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	   	  and  	  tdilc402.qstc  <>  0.0   
 	   	   	   	  selectdo   
 	   	   	   	   	  if not bcint.dll0000.migrate.standard.order.by.origin.for.purchase(   
 	   	   	   	   	   	   	   	  tcqms120.orgn,   
 	   	   	   	   	   	   	   	  tcqms120.orno,   
 	   	   	   	   	   	   	   	  tcqms120.pono,   
 	   	   	   	   	   	   	   	  tcqms120.opno,   
 	   	   	   	   	   	   	   	  tcqms120.srnb,   
 	   	   	   	   	   	   	   	  tcqms120.serb,   
 	   	   	   	   	   	   	   	  tcqms120.serc,   
 	   	   	   	   	   	   	   	  tcqms120.reco,   
 	   	   	   	   	   	   	   	  tcqms120.rsta,   
 	   	   	   	   	   	   	   	  inspection.status) then   
 	   	   	   	   	   	  order.line.ready.for.inspections  =  false   
 	   	   	   	   	  else   
 	   	   	   	   	   	  order.line.ready.for.inspections  =  true   
 	   	   	   	   	  endif   
 	   	   	   	   	  var.qmptc120.rsta  =  inspection.status  	     
 	   	   	   	  selectempty   
 	   	   	   	   	   	   	   	   	   	   	     
 	   	   	   	   	  if not bcint.dll0000.migrate.standard.order.by.origin.for.purchase(   
 	   	   	   	   	   	   	   	  tcqms120.orgn,   
 	   	   	   	   	   	   	   	  tcqms120.orno,   
 	   	   	   	   	   	   	   	  tcqms120.pono,   
 	   	   	   	   	   	   	   	  tcqms120.opno,   
 	   	   	   	   	   	   	   	  tcqms120.srnb,   
 	   	   	   	   	   	   	   	  tcqms120.serb,   
 	   	   	   	   	   	   	   	  tcqms120.serc,   
 	   	   	   	   	   	   	   	  tcqms120.reco,   
 	   	   	   	   	   	   	   	  tcqms120.rsta,   
 	   	   	   	   	   	   	   	  inspection.status) then   
 	   	   	   	   	   	  order.line.ready.for.inspections  =  false   
 	   	   	   	   	  endif   
 	   	   	   	   	  var.qmptc120.rsta  =  inspection.status  	     
 	   	   	   	  endselect   
 	   	   	  endselect   
 	   	  endif   
 	   	     
 	   	  if not order.line.ready.for.inspections then   
 	   	   	  continue   
 	   	  endif   
 	   	     
 	   	  var.qmptc120.orno  =  convert.number(  	  bcckon.act.pur,   
 	   	   	   	   	   	   	  tcqms120.orno)   
 	   	  var.qmptc120.seqn  =     
 	   	   	  get.pur.order.line.sequence.number(  	  tcqms120.srnb)   
 	   	  var.qmptc120.bpid  =  get.business.partner.code.for.QM( tcqms120.orno,   
 	   	  bcstc.orgn.suno,   
 	   	  o.errmess)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc120.orno  =  convert.number(  	  bcckon.act.sfc,  	     
 	   	   	   	   	   	   	  tcqms120.orno)   
 	   	  var.qmptc120.seqn  =  1   
 	   	  var.qmptc120.bpid  =  empty.string(1;9)   
 	   	  break   
 	  case tcqms.orgn.cwar.insp:   
 	   	  var.qmptc120.orno  =  empty.string(1;9)   
 	   	  var.qmptc120.bpid  =  empty.string(1;9)   
 	   	  break   
 	  endcase   
 	   	     
 	  if (( etol ( tcqms120.blmt )  =  5 ) or (etol ( tcqms120.blmt )  =  6 )) then   
 	   	  var.blmt  =  4   
 	  else   
 	   	  var.blmt  =  etol ( tcqms120.blmt )   
 	  endif   
 	     
 	  if not isspace(tcqms120.cdis) then  	   	     
 	   	  get.reason.for.rejection(bcreje.tcmcs005,tcqms120.cdis,o.errmess)   
 	  endif  	   	   	   	   	   	     
 	     
 	  select bcswh007.apno:var.qmptc120.apno,   
 	   	  bcswh007.apsq:var.qmptc120.apsq   
 	  from  	  bcswh007   
 	  where  	  bcswh007._index1  =  {  	  :tcqms120.orgn,   
 	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	  :tcqms120.srnb,   
 	   	   	   	   	  :tcqms120.serb,   
 	   	   	   	   	  :tcqms120.serc}   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	     
 	  dump 1 |  *  qmptc120   
 	   	   	   	   	   	   	     
 	  select tcqms100.*     
 	  from  	  tcqms100   
 	  where  	  tcqms100._index2  =  {  	  :tcqms120.orgn,   
 	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	  :tcqms120.opno,   
 	   	   	   	   	  :tcqms120.srnb,   
 	   	   	   	   	  :tcqms120.serb,   
 	   	   	   	   	  :tcqms120.serc}   
 	  and  	  (tcqms100.orgn  <>  tcqms.orgn.process and   
 	   	  tcqms100.orgn  <>  tcqms.orgn.matl.frm and   
 	   	  tcqms100.orgn  <>  tcqms.orgn.rou.ps )   
 	  selectdo   
 	   	  var.qmptc100.vrsn  =  1   
 	   	  var.qmptc100.ostp  =  get.order.specific.details.for.QM(   
 	   	  tcqms100.orgn,   
 	   	  tcqms100.orno,   
 	   	  tcqms100.pono,   
 	   	  tcqms100.opno)   
 	   	  if double.cmp(tcqms100.aper, 0.0, 0.0001)  =  0 then   
 	   	  var.qmptc100.acre  =  30   
 else   
 if double.cmp(tcqms100.aper, tcqms100.pper, 0.0001)  >  0 then   
 var.qmptc100.acre  =  10   
 else   
 var.qmptc100.acre  =  20   
 endif   
 endif    
 	   	  on case tcqms100.orgn   
 	   	  case tcqms.orgn.sales:   
 	   	   	  var.qmptc100.orno  =  convert.number(  	  bcckon.act.sls,   
 	   	   	   	   	   	   	   	  tcqms100.orno)   
 	   	   	  var.qmptc100.bpid  =  get.business.partner.code.for.QM(   
 	   	   	  tcqms100.orno,   
 	   	   	  bcstc.orgn.cuno,   
 	   	   	  o.errmess)   
 	   	   	  break   
 	   	  case tcqms.orgn.purchase:   
 	   	   	  var.qmptc100.orno  =  convert.number(  	  bcckon.act.pur,   
 	   	   	   	   	   	   	   	  tcqms100.orno)   
 	   	   	  var.qmptc100.bpid  =  get.business.partner.code.for.QM(   
 	   	   	  tcqms100.orno,   
 	   	   	  bcstc.orgn.suno,   
 	   	   	  o.errmess)   
 	   	   	  break   
 	   	  case tcqms.orgn.production:   
 	   	  case tcqms.orgn.matl.bom:   
 	   	  case tcqms.orgn.rou.ti:   
 	   	   	  var.qmptc100.orno  =  convert.number(  	  bcckon.act.sfc,   
 	   	   	   	   	   	   	   	  tcqms100.orno)   
 	   	   	  var.qmptc100.bpid  =  empty.string(1;9)   
 	   	   	  break   
 	   	  case tcqms.orgn.cwar.insp:   
 	   	   	  var.qmptc100.orno  =  empty.string(1;9)   
 	   	   	  var.qmptc100.bpid  =  empty.string(1;9)   
 	   	   	  break   
 	   	  endcase   
 	   	  dump 2 |  *  qmptc100   
 	  endselect   
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:100
:SCPAC:tc
:SCMOD:qms
:SFLNO:220
:ICOD:D
:QURY:START
	  get.reason.for.rejection(bcreje.tcmcs005,tcqms220.cdis,o.errmess)   
 	     
 	  dump 3 |  *  qmptc220   
 	     
 	  select  	  tcqms100.*     
 	  from  	  tcqms100   
 	  where  	  tcqms100._index3  =  {tcqms.orgn.cwar.insp,   
 	   	   	   	   	   	  :tcqms220.cprj,   
 	   	   	   	   	   	  :tcqms220.item,   
 	   	   	   	   	   	  :tcqms220.cntr,   
 	   	   	   	   	   	  :tcqms220.seqn}   
 and (tcqms100.orgn  <>  tcqms.orgn.process and   
 	  tcqms100.orgn  <>  tcqms.orgn.matl.frm and   
 	  tcqms100.orgn  <>  tcqms.orgn.rou.ps )   
 selectdo   
 	  var.qmptc100.ostp  =  get.order.specific.details.for.QM(   
 	   	  tcqms100.orgn,   
 	   	  tcqms100.orno,   
 	   	  tcqms100.pono,   
 	   	  tcqms100.opno)   
 	  if double.cmp(tcqms100.aper, 0.0, 0.0001)  =  0 then   
 	   	  var.qmptc100.acre  =  30   
 else   
 if double.cmp(tcqms100.aper, tcqms100.pper, 0.0001)  >  0 then   
 var.qmptc100.acre  =  10   
 else   
 var.qmptc100.acre  =  20   
 endif   
 endif   
 	  on case tcqms100.orgn   
 	  case tcqms.orgn.sales:   
 	   	  var.qmptc100.orno  =  convert.number(bcckon.act.sls,tcqms100.orno)   
 	   	  var.qmptc100.bpid  =  get.business.partner.code.for.QM(   
 	   	  tcqms100.orno,   
 	   	  bcstc.orgn.cuno,   
 	   	  o.errmess)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  var.qmptc100.orno  =  convert.number(bcckon.act.pur,tcqms100.orno)   
 	   	  var.qmptc100.bpid  =  get.business.partner.code.for.QM(   
 	   	  tcqms100.orno,   
 	   	  bcstc.orgn.suno,   
 	   	  o.errmess)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc100.orno  =  convert.number(bcckon.act.sfc,tcqms100.orno)   
 	   	  var.qmptc100.bpid  =  empty.string(1;9)   
 	   	  break   
 	  case tcqms.orgn.cwar.insp:   
 	  var.qmptc100.orno  =  empty.string(1;9)   
 	  var.qmptc100.bpid  =  empty.string(1;9)   
 	   	  break   
 	  endcase   
 	     
 	   	  dump 4 |  *  qmptc100   
 	  endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:100
:SCPAC:tc
:SCMOD:qms
:SFLNO:220
:ICOD:S
:QURY:START
select  	  tcqms220.*     
from 	  tcqms220
where 	  tcqms220.srno  =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:100
:SCPAC:tc
:SCMOD:qms
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:130
:SCPAC:tc
:SCMOD:qms
:SFLNO:120
:ICOD:D
:QURY:START
	  if tdilc000.iilc  =  tcyesno.yes then   
 	   	  ILC.IMPLEMENTED  =  1   
 	  else   
 	   	  ILC.IMPLEMENTED  =  0   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:130
:SCPAC:tc
:SCMOD:qms
:SFLNO:120
:ICOD:S
:QURY:START
select  	  tdilc000.*    
from 	  tdilc000   
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:130
:SCPAC:tc
:SCMOD:qms
:SFLNO:120
:ICOD:X
:QURY:START
select  	  tcqms120.*     
 from  	  tcqms120   
 where  	  (tcqms120.orgn  <>  tcqms.orgn.process and   
 	  tcqms120.orgn  <>  tcqms.orgn.matl.frm and   
 	  tcqms120.orgn  <>  tcqms.orgn.rou.ps)   
 order by tcqms120._index1   
 selectdo   
 	  var.qmptc120.clot  =  ""   
 	  var.qmptc120.cser  =  ""   
 	  var.qmptc130.idat  =  utc(0,0)  	   	   	   	  |# FP10.n    
 	  select  	  tiitm001.kltc   
 	  from  	  tiitm001   
 	  where  	  tiitm001._index1  =  {:tcqms120.item}   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	     
 	  if tiitm001.kltc  =  tckltc.batch or tiitm001.kltc  =  tckltc.unit then   
 	   	  if tiitm001.kltc  =  tckltc.batch then   
 	   	   	  var.qmptc120.clot  =  tcqms120.clot   
 	   	  else   
 	   	   	  var.qmptc120.cser  =  tcqms120.clot   
 	   	  endif   
 	  on case tcqms120.orgn  	     
 	  case tcqms.orgn.sales:   
 	   	  order.line.ready.for.inspections  =  true   
 	   	  if ILC.IMPLEMENTED then   
 	   	   	  select  	  tdilc401.*     
 	   	   	  from  	  tdilc401   
 	   	   	  where  	  tdilc401._index1  =  {  	  tdilc.koob.act.sls,   
 	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	  and  	  tdilc401.proc  =  tcyesno.no   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	   	  order.line.ready.for.inspections  =  false   
 	   	   	  endselect   
 	   	   	  select  	  tdilc401.*    	   	  |# FP10.sn    
 	   	   	  from  	  tdilc401   
 	   	   	  where  	  tdilc401._index1  =  {  	  tdilc.koob.act.sls,   
 	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	  and  	  tdilc401.proc  =  tcyesno.yes   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	   	  var.qmptc130.idat  =  utc(tdilc401.date,0)   
 	   	   	  endselect  	   	   	   	  |# FP10.en  	     
 	   	  endif   
 	   	     
 	   	  if not order.line.ready.for.inspections then   
 	   	   	  continue   
 	   	  endif   
 	   	  var.qmptc120.orno  =  convert.number(  	  bcckon.act.sls,   
 	   	   	   	   	   	   	  tcqms120.orno)   
 	   	  var.qmptc120.seqn  =     
 	   	   	  get.sls.order.line.sequence.number(   
 	   	   	   	   	   	   	   	  tcqms120.orno,   
 	   	   	   	   	   	   	   	  tcqms120.pono,   
 	   	   	   	   	   	   	   	  tcqms120.srnb)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  order.line.ready.for.inspections  =  true   
 	   	  if ILC.IMPLEMENTED then   
 	   	   	  select tdilc402.*     
 	   	   	  from  	  tdilc402   
 	   	   	  where  	  tdilc402._index1  =  {  	  tdilc.kooa.act.pur,   
 	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	  and  	  tdilc402.astc  <>  0.0   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	   	  order.line.ready.for.inspections  =  true   
 	   	   	  selectempty   
 	   	   	   	  select  	  tdilc402.*     
 	   	   	   	  from  	  tdilc402   
 	   	   	   	  where  	  tdilc402._index1  =  {  	  tdilc.kooa.stock.transfer,   
 	   	   	   	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	   	   	   	  :tcqms120.srnb}   
 	   	   	   	  and  	  tdilc402.qstc  <>  0.0   
 	   	   	   	  selectdo   
 	   	   	   	   	  if not bcint.dll0000.migrate.standard.order.by.origin.for.purchase(   
 	   	   	   	   	   	   	   	  tcqms120.orgn,   
 	   	   	   	   	   	   	   	  tcqms120.orno,   
 	   	   	   	   	   	   	   	  tcqms120.pono,   
 	   	   	   	   	   	   	   	  tcqms120.opno,   
 	   	   	   	   	   	   	   	  tcqms120.srnb,   
 	   	   	   	   	   	   	   	  tcqms120.serb,   
 	   	   	   	   	   	   	   	  tcqms120.serc,   
 	   	   	   	   	   	   	   	  tcqms120.reco,   
 	   	   	   	   	   	   	   	  tcqms120.rsta,   
 	   	   	   	   	   	   	   	  inspection.status) then   
 	   	   	   	   	   	  order.line.ready.for.inspections  =  false   
 	   	   	   	   	  else   
 	   	   	   	   	   	  order.line.ready.for.inspections  =  true   
 	   	   	   	   	  endif   
 	   	   	   	  selectempty   
 	   	   	   	   	   	   	   	   	   	   	     
 	   	   	   	   	  if not bcint.dll0000.migrate.standard.order.by.origin.for.purchase(   
 	   	   	   	   	   	   	   	  tcqms120.orgn,   
 	   	   	   	   	   	   	   	  tcqms120.orno,   
 	   	   	   	   	   	   	   	  tcqms120.pono,   
 	   	   	   	   	   	   	   	  tcqms120.opno,   
 	   	   	   	   	   	   	   	  tcqms120.srnb,   
 	   	   	   	   	   	   	   	  tcqms120.serb,   
 	   	   	   	   	   	   	   	  tcqms120.serc,   
 	   	   	   	   	   	   	   	  tcqms120.reco,   
 	   	   	   	   	   	   	   	  tcqms120.rsta,   
 	   	   	   	   	   	   	   	  inspection.status) then   
 	   	   	   	   	   	  order.line.ready.for.inspections  =  false   
 	   	   	   	   	  endif   
 	   	   	   	  endselect   
 	   	   	  endselect   
 	   	   	   	   	   	   	   	  |# FP10.sn   
 	   	   	  var.qmptc130.idat  =  utc(tdilc402.date,0)   
 	   	   	   	   	   	   	   	  |# FP10.en   
 	   	  endif   
 	   	     
 	   	  if not order.line.ready.for.inspections then   
 	   	   	  continue   
 	   	  endif   
 	   	     
 	   	  var.qmptc120.orno  =  convert.number(  	  bcckon.act.pur,   
 	   	   	   	   	   	   	  tcqms120.orno)   
 	   	  var.qmptc120.seqn  =     
 	   	   	  get.pur.order.line.sequence.number(  	  tcqms120.srnb)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc120.orno  =  convert.number(  	  bcckon.act.sfc,  	     
 	   	   	   	   	   	   	  tcqms120.orno)   
 	   	  var.qmptc120.seqn  =  1   
 	   	  break   
 	  case tcqms.orgn.cwar.insp:   
 	   	  var.qmptc120.orno  =  empty.string(1;9)   
 	   	  break   
 	  endcase   
 	   	     
 	  select bcswh007.apno:var.qmptc120.apno,   
 	   	  bcswh007.apsq:var.qmptc120.apsq   
 	  from  	  bcswh007   
 	  where  	  bcswh007._index1  =  {  	  :tcqms120.orgn,   
 	   	   	   	   	  :tcqms120.orno,   
 	   	   	   	   	  :tcqms120.pono,   
 	   	   	   	   	  :tcqms120.srnb,   
 	   	   	   	   	  :tcqms120.serb,   
 	   	   	   	   	  :tcqms120.serc}   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	     
 	  dump 1   
 	  endif   
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:160
:SCPAC:tc
:SCMOD:qms
:SFLNO:101
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:160
:SCPAC:tc
:SCMOD:qms
:SFLNO:101
:ICOD:S
:QURY:START
select tcqms101.*     
from tcqms101
where tcqms101.emno  <>  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:160
:SCPAC:tc
:SCMOD:qms
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:165
:SCPAC:tc
:SCMOD:qms
:SFLNO:101
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:165
:SCPAC:tc
:SCMOD:qms
:SFLNO:101
:ICOD:S
:QURY:START
select tcqms101.*     
from tcqms101
where tcqms101.skll  <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:165
:SCPAC:tc
:SCMOD:qms
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:301
:SCPAC:tc
:SCMOD:qms
:SFLNO:301
:ICOD:D
:QURY:START
	  on case tcqms301.orgn   
 	  case tcqms.orgn.sales:   
 	   	  var.qmptc301.orno  =  convert.number(  	  bcckon.act.sls,   
 	   	   	   	   	   	   	  tcqms301.orno)   
 	   	  var.qmptc301.bpid  =  get.business.partner.code.for.QM( tcqms301.orno,   
 	   	  bcstc.orgn.cuno,   
 	   	  errmess)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  var.qmptc301.orno  =  convert.number(  	  bcckon.act.pur,   
 	   	   	   	   	   	   	  tcqms301.orno)   
 	   	  var.qmptc301.bpid  =  get.business.partner.code.for.QM( tcqms301.orno,   
 	   	  bcstc.orgn.suno,   
 	   	  errmess)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc301.orno  =  convert.number(  	  bcckon.act.sfc,  	     
 	   	   	   	   	   	   	  tcqms301.orno)   
 	   	  var.qmptc301.bpid  =  empty.string(1;9)   
 	   	  break   
 	  case tcqms.orgn.cwar.insp:   
 	   	  var.qmptc301.orno  =  empty.string(1;9)   
 	   	  var.qmptc301.bpid  =  empty.string(1;9)   
 	   	  break   
 	  endcase   
 	     
 	  if tcqms301.orgn  =  tcqms.orgn.purchase then   
 	   	  var.qmptc301.seqn  =  get.pur.order.line.sequence.number(   
 	   	   	   	   	   	   	  tcqms301.srnb)   
 	   	  break   
 	  endif   
 	     
 	  if tcqms301.orgn  =  tcqms.orgn.sales then   
 	   	  var.qmptc301.seqn  =  get.sls.order.line.sequence.number(   
 	   	   	   	   	   	   	  tcqms301.orno,   
 	   	   	   	   	   	   	  tcqms301.pono,   
 	   	   	   	   	   	   	  tcqms301.srnb)   
 	  endif   
 	     
 	  if tcqms301.orgn  =  tcqms.orgn.production then   
 	   	  var.qmptc301.seqn  =  1   
 	  endif   
 	     
 	  if tcqms301.orgn  =  tcqms.orgn.matl.bom then   
 	   	  var.qmptc301.seqn  =  1   
 	  endif   
 	     
 	  if tcqms301.orgn  =  tcqms.orgn.rou.ti then   
 	   	  var.qmptc301.seqn  =  1   
 	  endif   
 	     
 	  if (( etol ( tcqms301.blmt )  =  5 ) or (etol ( tcqms301.blmt )  =  6 )) then   
 	   	  var.qmptc301.blmt  =  4   
 	  else   
 	   	  var.qmptc301.blmt  =  etol ( tcqms301.blmt )   
 	  endif  	     
 	  select bcswh007.apno:var.qmptc301.apno,   
 	   	  bcswh007.apsq:var.qmptc301.apsq   
 	  from  	  bcswh007   
 	  where  	  bcswh007._index1  =  {  	  :tcqms301.orgn,   
 	   	   	   	   	  :tcqms301.orno,   
 	   	   	   	   	  :tcqms301.pono,   
 	   	   	   	   	  :tcqms301.srnb,   
 	   	   	   	   	  :tcqms301.serb,   
 	   	   	   	   	  :tcqms301.serc}   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	     
 	  if not isspace(tcqms301.cdis) then  	   	   	     
 	   	  get.reason.for.rejection(  	  bcreje.tcmcs005,   
 	   	   	   	   	   	  tcqms301.cdis,   
 	   	   	   	   	   	  errmess)   
 	   	  var.qmptc301.cdis  =  bcstc017.newr   
 	  else   
 	   	  var.qmptc301.cdis  =  ""    
 	  endif  	   	   	   	   	   	     
 	  var.qmptc301.rsta  =  5 	  	 |#10.5.1.n   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:301
:SCPAC:tc
:SCMOD:qms
:SFLNO:301
:ICOD:S
:QURY:START
select  	  tcqms301.*     
from 	  tcqms301
where 	  (tcqms301.orgn  <>  tcqms.orgn.process and   
 	  tcqms301.orgn  <>  tcqms.orgn.matl.frm and   
 	  tcqms301.orgn  <>  tcqms.orgn.rou.ps)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:301
:SCPAC:tc
:SCMOD:qms
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:305
:SCPAC:tc
:SCMOD:qms
:SFLNO:305
:ICOD:D
:QURY:START
var.qmptc305.vrsn  =  1   
 var.qmptc305.ostp  =  get.order.specific.details.for.QM(   
 	   	  tcqms305.orgn,   
 	   	  tcqms305.orno,   
 	   	  tcqms305.pono,   
 	   	  tcqms305.opno)   
 if double.cmp(tcqms305.aper, 0.0, 0.0001)  =  0 then   
 var.qmptc305.acre  =  30   
 else   
 if double.cmp(tcqms305.aper, tcqms305.pper, 0.0001)  >  0 then   
 var.qmptc305.acre  =  10   
 else   
 var.qmptc305.acre  =  20   
 endif   
 endif   
 	  on case tcqms305.orgn   
 	  case tcqms.orgn.sales:   
 	   	  var.qmptc305.orno  =  convert.number(  	  bcckon.act.sls,   
 	   	   	   	   	   	   	  tcqms305.orno)   
 	   	  var.qmptc305.bpid  =  get.business.partner.code.for.QM(   
 	   	  tcqms305.orno,   
 	   	  bcstc.orgn.cuno,   
 	   	  o.errmess)   
 	   	  break   
 	  case tcqms.orgn.purchase:   
 	   	  var.qmptc305.orno  =  convert.number(  	  bcckon.act.pur,   
 	   	   	   	   	   	   	  tcqms305.orno)   
 	   	  var.qmptc305.bpid  =  get.business.partner.code.for.QM(   
 	   	  tcqms305.orno,   
 	   	  bcstc.orgn.suno,   
 	   	  o.errmess)   
 	   	  break   
 	  case tcqms.orgn.production:   
 	  case tcqms.orgn.matl.bom:   
 	  case tcqms.orgn.rou.ti:   
 	   	  var.qmptc305.orno  =  convert.number(  	  bcckon.act.sfc,  	     
 	   	   	   	   	   	   	  tcqms305.orno)   
 	   	  var.qmptc305.bpid  =  empty.string(1;9)   
 	   	  break   
 	  case tcqms.orgn.cwar.insp:   
 	   	  var.qmptc305.orno  =  empty.string(1;9)   
 	   	  var.qmptc305.bpid  =  empty.string(1;9)   
 	   	  break   
 	  endcase   
 	  |   *  Purchase  **  Sequence is always set correctly in field tcqms120.srnb   
 	  if tcqms305.orgn  =  tcqms.orgn.purchase then   
 	   	  var.qmptc305.seqn  =     
 	   	   	  get.pur.order.line.sequence.number(  	  tcqms305.srnb)   
 	  endif   
 	     
 	  if tcqms305.orgn  =  tcqms.orgn.sales then   
 	   	  var.qmptc305.seqn  =     
 	   	   	  get.sls.order.line.sequence.number(   
 	   	   	   	   	   	   	   	  tcqms305.orno,   
 	   	   	   	   	   	   	   	  tcqms305.pono,   
 	   	   	   	   	   	   	   	  tcqms305.srnb)   
 	  endif   
 	     
 	  if tcqms305.orgn  =  tcqms.orgn.production then   
 	   	  var.qmptc305.seqn  =  1   
 	  endif   
 	     
 	  if tcqms305.orgn  =  tcqms.orgn.matl.bom then   
 	   	  var.qmptc305.seqn  =  1   
 	  endif   
 	     
 	  if tcqms305.orgn  =  tcqms.orgn.rou.ti then   
 	   	  var.qmptc305.seqn  =  1   
 	  endif   
 	     
 	  select bcswh007.apno:var.qmptc305.apno,   
 	   	  bcswh007.apsq:var.qmptc305.apsq   
 	  from  	  bcswh007   
 	  where  	  bcswh007._index1  =  {  	  :tcqms305.orgn,   
 	   	   	   	   	  :tcqms305.orno,   
 	   	   	   	   	  :tcqms305.pono,   
 	   	   	   	   	  :tcqms305.srnb,   
 	   	   	   	   	  :tcqms305.serb,   
 	   	   	   	   	  :tcqms305.serc}   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	     
 	  dump 1  	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:305
:SCPAC:tc
:SCMOD:qms
:SFLNO:305
:ICOD:S
:QURY:START
select  	  tcqms305.*    
from 	  tcqms305
where 	  (tcqms305.orgn  <>  tcqms.orgn.process   
 and  	  tcqms305.orgn  <>  tcqms.orgn.matl.frm   
 and  	  tcqms305.orgn  <>  tcqms.orgn.rou.ps)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:305
:SCPAC:tc
:SCMOD:qms
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:306
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:D
:QURY:START
get.characteristic.option.for.QM(tcqms306.char, tcqms306.oset,o.errmess)   
 var.qmptc306.acre  =  inspection.order.line.determine.result(tcqms306.iorn, tcqms306.pono)   
 var.qmptc306.osta  =  4 	 |#10.5.1.n   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:306
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:S
:QURY:START
select tcqms306.*     
from tcqms306
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:306
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:315
:SCPAC:tc
:SCMOD:qms
:SFLNO:310
:ICOD:D
:QURY:START
select tcqms306.char, tcqms306.tuni, tcqms306.tseq   
 from tcqms306   
 where tcqms306._index1  =  {:tcqms315.iorn, :tcqms315.pono}   
 as set with 1 rows   
 selectdo   
 endselect   
 select tcqms310.tqua   
 from tcqms310   
 where tcqms310._index1  =  {:tcqms315.iorn, :tcqms315.saml}   
 as set with 1 rows   
 selectdo   
 endselect   
 get.characteristic.option.for.QM(tcqms306.char, tcqms315.oset,o.errmess)   
 	     
 if isspace(bcsqm001.ostn) then   
 bcsqm001.ostn  =  tcqms315.oset   
 endif   
 var.qmptc315.text  =  0 	  	 |#10.5.1.n   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:315
:SCPAC:tc
:SCMOD:qms
:SFLNO:310
:ICOD:S
:QURY:START
select tcqms315.*     
from tcqms315
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:315
:SCPAC:tc
:SCMOD:qms
:SFLNO:310
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:360
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:360
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:S
:QURY:START
select tcqms306.*     
from tcqms306
where tcqms306.emno  <>  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:360
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:365
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:365
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:S
:QURY:START
select tcqms306.*     
from tcqms306
where tcqms306.skll  <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:qm
:TCMOD:ptc
:TFLNO:365
:SCPAC:tc
:SCMOD:qms
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  var.tccom000.owne  =  1   
 	  selectempty   
 	   	  var.tccom000.srvi  =  2   
 	   	  var.tccom000.owne  =  1   
 	  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 tiedm000.*     
 	  from  	  tiedm000   
 	  where  	  tiedm000._compnr  =  :tccom000.ncmp   
 	  as set with 1 rows  	   	   	   	  |# 251714.n   
 	  selectdo   
 	   	  var.tccom000.erac  =  tiedm000.ecoi   
 	  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   
 	  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   
 	  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   
 	  select 	 tdsmi000.smii 	  	  	  	 |#800  -  210121.sn   
 	  from 	  	 tdsmi000   
 	  where  	 tdsmi000._compnr  =  :tccom000.ncmp   
 	  as set with 1 rows   
 	  selectdo   
 	  	 var.tccom000.smii  =  tdsmi000.smii   
 	  endselect 	  	  	  	  	  	 |#800  -  210121.en   
 	  get.odm.parameter()   
 	 get.finance.archive.company( 	  	  	  	 |#LN10.4.2.1.sn   
 	  	  	  	  	 tccom000.ncmp,   
 	  	  	  	  	 var.tccom000.darc) 	 |#LN10.4.2.1.en   
 	  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   
 	  var.tccom000.prci  =  get.product.classification() |#LN10.6.n   
 	  dump 1
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:001
:SCPAC:tc
:SCMOD:com
:SFLNO:001
:ICOD:X
:QURY:START
	   	   	   	   	   	  |# 205573.en   
 	   	   	   	   	   	     
 select  	  tccom001.*     
 from  	  tccom001   
 selectdo   
 	  get.logon.code.for.theemployee()  	   	   	   	   	  |# 215115.n   
 	  var.tccom001.seak  =  tccom001.nama(1; 16)   
 	  if not isspace(tccom001.cwoc) then   
 	   	  var.tccom001.cwoc  =  tccom001.cwoc   
 	  else   
 	   	  if service.employee.must.be.created(tccom001.emno) then   
 	   	   	  var.tccom001.cwoc  =  get.default.service.department()   
 	   	  else   
 	   	   	  var.tccom001.cwoc  =  empty()   
 	   	  endif   
 	  endif   
 	  var.tccom001.wgrt  =  fill.mc.field.double(tccom001.wgrt,1)   
 	  if get.hourly.labor.rate( | tccom001.wgrt,   
 	   	   	   	  var.tccom001.wgrt,   
 	   	   	   	  tccom001.rats,   
 	   	   	   	  dummy.err.mess)  =  0 then   
 	   	  var.tccom001.clrt  =  bcsbp003.nrtc   
 	  else   
 |  	   	  var.tccom001.clrt  =  empty()  	   	   	  |# LN10.4.1.o   
 	   	  var.tccom001.clrt  =  ""  	   	   	   	  |# LN10.4.1.n   
 	  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  	   	  |# FP7.so   
 |  	   	  tccom001.dpwk  <>  0.0 or   
 |  	   	  tccom001.hrsd  <>  0.0 or   
 |  	   	  tccom001.rats  <>  0.0 then   
 |  	   	   	  |   *  Dump for filling tppdm801  -  Project Employees   
 |  	   	   	  dump 3   
 |  	  endif  	   	   	   	   	   	  |# FP7.eo   
 	  if tppdm000.pprj  =  tppdm.yeno.yes then  	  |# FP7.sn   
 	   	  |   *  If project is implemented, any employee can   
 	   	  |   *  be used in the Labor Costs session; even   
 	   	  |   *  if e.g. trade group is empty.   
 	   	  dump 3   
 	  endif  	   	   	   	   	   	  |# FP7.en   
 	   	     
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  endif  	   	     
 	  var.tccom100.bpid  =  bcstc008.bpid   
 	  if bcstc008.sndr  =  empty then  	     
 	   	  var.tccom100.sndr  =  tcyesno.no   
 	  else  	   	   	   	   	     
 	   	  var.tccom100.sndr  =  bcstc008.sndr   
 	  endif  	   	   	   	   	     
 	  if var.tccom100.sndr  =  tcyesno.yes then   
 	   	  |   *  Exception: if a One  -  Time BP, then Parent BP   
 	   	  |   *  should not be filled.   
 	   	  var.tccom100.prbp  =  ""    
 	  else   
 	   	  var.tccom100.prbp  =  hold.tccom100.prbp   
 	  endif  	   	   	   	   	     
 	  if tccom010.inrl  =  empty   
 	  or tccom010.iscn  =  0  	   	     
 	  |   *  If Affiliated Comp  ==  0, then Affiliated :  =  No.   
 	  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)  	     
 	  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   
 	  get.dial.codes.of.country( bcstc004.ccty,   
 	   	   	   	   	  g.dialcode.for.telephone,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  var.phone.number  =  determine.communication.number(   
 	   	   	   	   	  bcstc004.telp,   
 	   	   	   	   	  g.dialcode.for.telephone)   
 	  var.country.for.phone.number  =  determine.country.for.communication.number(   
 	   	   	   	   	  bcstc004.telp,   
 	   	   	   	   	  g.dialcode.for.telephone)   
 	  var.fax.number  =  determine.communication.number(   
 	   	   	   	   	  bcstc004.tefx,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  var.country.for.fax.number  =  determine.country.for.communication.number(   
 	   	   	   	   	  bcstc004.tefx,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	     
 	  dump 1 |   *  tccom100 from customers   
 	     
 	  if (tccom010.comp  <>  0) then   
 	   	  if get.enterprise.unit(tccom010.comp,hold.cmpnr, o.mess) then   
 	   	   	  var.tccom110.cofc  =  ""   
 	   	   	  var.tccom110.lcmp  =  0   
 	   	  else   
 	   	   	  var.tccom110.cofc  =  bcstc018.sofd   
 	   	   	  var.tccom110.lcmp  =  bcstc018.lcmp   
 	   	  endif   
 	  else   
 	   	  var.tccom110.cofc  =  ""   
 	   	  var.tccom110.lcmp  =  0    
 	  endif   
 	   	     
 	  if isspace(var.tccom100.prbp) or   
 	  isspace(tccom010.pcpr) then   
 	   	  var.tccom110.bppr  =  ""    
 	  else  	   	   	   	     
 	   	  if get.business.partner(tccom010.pcpr,bcstc.orgn.cuno, o.mess) then   
 	   	   	  var.tccom110.bppr  =  ""    
 	   	  else   
 	   	   	  var.tccom110.bppr  =  bcstc008.bpid   
 	   	  endif   
 	  endif  	     
 	     
 	  if isspace(var.tccom100.prbp) or   
 	  isspace(tccom010.ccus) then   
 	  |# fill Bp for statistics if ccus is filled and parent BP is filled.   
 	   	  var.tccom110.bpus  =  ""    
 	  else   
 	   	  if get.business.partner(tccom010.ccus,bcstc.orgn.cuno, o.mess) then   
 	   	   	  var.tccom110.bpus  =  ""    
 	   	  else   
 	   	   	  var.tccom110.bpus  =  bcstc008.bpid   
 	   	  endif   
 	  endif  	   	   	   	     
 	     
 	  dump 2 |   *  tccom110   
 	  dump 3 |   *  tccom111   
 	  if isspace(tccom010.cinm) then   
 	   	  var.tccom112.cinm  =  bcstc000.cinm   
 	  else   
 	   	  var.tccom112.cinm  =  tccom010.cinm   
 	  endif   
 	  if not isspace(tccom010.crat) then   
 	   	  var.tccom112.crat  =  tccom010.crat   
 	  else   
 	   	  var.tccom112.crat  =  bcstc000.crat   
 	  endif  	   	   	   	     
 	  var.tccom112.cvyn  =  get.tax.flag.via.bp(tccom010.cuno, bcstc.orgn.cuno,   
 	   	   	  o.mess)   
 	  if isspace(tccom010.pctf) then  	   	   	   	   	  |# 241014.sn   
 	   	  var.tccom112.pfbp  =  ""    
 	  else  	   	   	   	   	   	   	   	  |# 241014.en   
 	   	  if get.business.partner(tccom010.pctf,bcstc.orgn.cuno, o.mess) then  	     
 	   	   	  var.tccom112.pfbp  =  ""    
 	   	  else   
 	   	   	  var.tccom112.pfbp  =  bcstc008.bpid   
 	   	  endif   
 	  endif  	   	   	   	   	   	   	   	  |# 241014.n  	     
 	  dump 4 |   *  tccom112   
 	  dump 5 |   *  tccom114   
 	  if tccom010.lidt  <>  0 then   
 	  dump 14 |  	    *  tccom105   
 	  endif   
 	  add.business.partner.to.list(var.tccom100.bpid)  	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:F
:QURY:START
	  sort.bp.code.list()  	   	   	   	
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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  	   	   	     
 	  |   *  Exception: if a One  -  Time BP, then the Parent BP should not be   
 	  |   *  filled.   
 	   	  var.tccom100.prbp  =  ""    
 	  else   
 	   	  var.tccom100.prbp  =  hold.tccom100.prbp   
 	  endif  	   	   	   	   	   	   	     
 	  if tccom020.inrl  =  empty   
 	  or tccom020.iscn  =  0  	   	   	     
 	  |   *  If Affiliated Comp  ==  0, then Affiliated :  =  No.   
 	  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 isspace(tccom020.scus) then  	   	   	   	   	  |# 241014.sn   
 	   	  var.tccom120.scus  =  ""    
 	  else  	   	   	   	   	   	   	   	  |# 241014.en   
 	   	  if get.business.partner(tccom020.scus, bcstc.orgn.suno, o.mess) then   
 	   	   	  var.tccom120.scus  =  ""    
 	   	  else   
 	   	   	  var.tccom120.scus  =  bcstc008.bpid   
 	   	  endif   
 	  endif  	   	   	   	   	   	   	   	  |# 241014.n   
 	  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:   
 	   	  if purchase.contract.or.order.found(tccom020.suno) then   
 	   	   	  var.tccom100.bpst  =  2 | active   
 	   	   	  var.tccom120.bpst  =  3 | inactive   
 	   	  else  	   	     
 	   	   	  var.tccom100.bpst  =  1   
 	   	   	  var.tccom120.bpst  =  1   
 	   	  endif  	   	     
 	   	  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   
 	  get.dial.codes.of.country(  	  bcstc004.ccty,   
 	   	   	   	   	  g.dialcode.for.telephone,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  var.phone.number  =  determine.communication.number(   
 	   	   	   	   	  bcstc004.telp,   
 	   	   	   	   	  g.dialcode.for.telephone)   
 	  var.country.for.phone.number  =  determine.country.for.communication.number(   
 	   	   	   	   	  bcstc004.telp,   
 	   	   	   	   	  g.dialcode.for.telephone)   
 	  var.fax.number  =  determine.communication.number(   
 	   	   	   	   	  bcstc004.tefx,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  var.country.for.fax.number  =  determine.country.for.communication.number(   
 	   	   	   	   	  bcstc004.tefx,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  if not bp.code.in.sorted.list(var.tccom100.bpid) then   
 	   	  dump 6 |   *  tccom100 from suppliers   
 	  endif  	   	   	   	   	   	   	     
 	     
 	  if (tccom020.comp  <>  0) then   
 	   	  if get.enterprise.unit(tccom020.comp, hold.cmpnr, o.mess) then   
 	   	   	  var.tccom120.cofc  =  ""   
 	   	   	  var.tccom120.lcmp  =  0   
 	   	  else   
 	   	   	  var.tccom120.cofc  =  bcstc018.pofd   
 	   	   	  var.tccom120.lcmp  =  bcstc018.lcmp   
 	   	  endif   
 	  else   
 	   	  var.tccom120.cofc  =  ""    
 	   	  var.tccom120.lcmp  =  0   
 	  endif   
 	  link.to.sub  =  2   
 	  select tirou001.*     
 	  from  	  tirou001   
 	  where tirou001._index4  =  {:tccom020.suno}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  link.to.sub  =  1   
 	   	  if get.enterprise.unit(tirou001.ncmp, hold.cmpnr, o.mess) then   
 	   	   	  var.tccom120.cofc  =  ""    
 	   	  else   
 	   	   	  var.tccom120.cofc  =  bcstc018.pofd   
 	   	  endif   
 	  endselect   
 	   	   	     
 	  dump 7 |   *  tccom120   
 	  dump 8 |   *  tccom121   
 	  if (link.to.sub  =  1) then   
 	   	  var.tccom122.ccnt(1;9)  =  ""    
 	  else  	     
 	   	  var.tccom122.ccnt(1;9)  =  hold.ccnt   
 	  endif   
 	  if tccom020.subc  =  empty then   
 	   	  tccom020.subc  =  tcyesno.no   
 	  endif   
 	  var.tccom122.cvyn  =  get.tax.flag.via.bp(tccom020.suno, bcstc.orgn.suno,   
 	   	   	  o.mess)   
 	  if not isspace(tccom020.cfcc) then   
 	   	  converted.cuno  =  bcint.dll0000.convert.factoring.code.for.bcstc008(tccom020.cfcc)  	  |# 1431629.n   
 |  	   	  if get.business.partner(tccom020.cfcc, bcstc.orgn.fcomp, o.mess) then  	   	  |# 1431629.o   
 	   	  if get.business.partner(converted.cuno, bcstc.orgn.fcomp, o.mess) then  	   	  |# 1431629.n   
 	   	   	  var.tccom122.ptbp  =  ""    
 	   	  else   
 	   	   	  var.tccom122.ptbp  =  bcstc008.bpid   
 	   	  endif   
 	  else   
 	   	  var.tccom122.ptbp  =  ""    
 	  endif   
 	  dump 9 |   *  tccom122   
 	  dump 10 |   *  tccom124
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:020
:ICOD:X
:QURY:START
free.mem(bp.code.list)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 |  	  converted.cuno  =  string.set$(" ", 6)  	   	   	   	   	   	   	  |# 1431629.so   
 |  	  converted.cuno(4;3)  =  tcmcs025.cfcc  	   	   	   	   	   	  |# 1431629.eo   
 	  converted.cuno  =  bcint.dll0000.convert.factoring.code.for.bcstc008(tcmcs025.cfcc)  	  |# 1431629.n   
 	  if get.business.partner(converted.cuno,bcstc.orgn.fcomp, o.mess) then   
 	   	  var.tccom100.bpid  =  ""    
 	   	  continue   
 	  endif   
 	  var.tccom100.bpid  =  bcstc008.bpid   
 	  if bcstc008.sndr  =  empty then   
 	  |# 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.   
 	   	  var.tccom100.sndr  =  tcyesno.no   
 	  else  	   	   	   	     
 	   	  var.tccom100.sndr  =  bcstc008.sndr  	     
 	  endif  	   	     
 	  if var.tccom100.sndr  =  tcyesno.yes then  	     
 	   	  |   *  Exception: if a One  -  Time BP, then Parent BP   
 	   	  |   *  should not be filled.   
 	   	  var.tccom100.prbp  =  ""    
 	  else   
 	   	  var.tccom100.prbp  =  hold.tccom100.prbp   
 	  endif  	   	   	   	   	   	     
 	  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   
 	  get.dial.codes.of.country(  	  bcstc004.ccty,   
 	   	   	   	   	  g.dialcode.for.telephone,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  var.phone.number  =  determine.communication.number(   
 	   	   	   	   	  bcstc004.telp,   
 	   	   	   	   	  g.dialcode.for.telephone)   
 	  var.country.for.phone.number  =  determine.country.for.communication.number(   
 	   	   	   	   	  bcstc004.telp,   
 	   	   	   	   	  g.dialcode.for.telephone)   
 	  var.fax.number  =  determine.communication.number(   
 	   	   	   	   	  bcstc004.tefx,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  var.country.for.fax.number  =  determine.country.for.communication.number(   
 	   	   	   	   	  bcstc004.tefx,   
 	   	   	   	   	  g.dialcode.for.fax)   
 	  dump 11 |   *  tccom100 From Factoring Companies   
 	  dump 12 |   *  tccom124
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:705
:SCPAC:tc
:SCMOD:com
:SFLNO:705
:ICOD:D
:QURY:START
	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:705
:SCPAC:tc
:SCMOD:com
:SFLNO:705
:ICOD:F
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:705
:SCPAC:tc
:SCMOD:com
:SFLNO:705
:ICOD:S
:QURY:START
select 	 tccom705.*   
from 	 tccom705
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:705
:SCPAC:tc
:SCMOD:com
:SFLNO:705
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:030
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select 	 bcstc018.*     
from 	 bcstc018
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:030
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:D
:QURY:START
	 |  *  It is assumed that the office codes, as defined in bcstc018,   
 	 |  *    -  do not overlap with wc codes in tirou001,   
 	 |  *    -  are unique within the Enterprise Unit   
 	 |  *    -  are unique within a logistical company.   
 	 |  *  Insert key Entity (tcemm110) and Departments (tcemm124)   
 	 |  *  Purchase Office   
 	 dump.2.department( 	 bcstc018.pofd,   
 	  	  	  	 var.enum.pur.office, bcstc018.entc,   
 	  	  	  	 bcstc018.lcmp, bcstc018.fcmp )   
 	  	  	    
 	 |  *  Sales Office   
 	 dump.2.department( 	 bcstc018.sofd,   
 	  	  	  	 var.enum.sls.office, bcstc018.entc,   
 	  	  	  	 bcstc018.lcmp, bcstc018.fcmp )   
 	 |  *  Service Office   
 	 dump.2.department( 	 bcstc018.srfd,   
 	  	  	  	 var.enum.service.dept, bcstc018.entc,   
 	  	  	  	 bcstc018.lcmp, bcstc018.fcmp )   
 	 |  *  Work Center   
 	 |  *  Is an existing work center, will be handled by migrate tirou001   
 	    
 	 |  *  Shipping Office   
 	 dump.2.department( 	 bcstc018.shod,   
 	  	  	  	 var.enum.shipping.office, bcstc018.entc,   
 	  	  	  	 bcstc018.lcmp, bcstc018.fcmp )   
 	 |  *  Accounting Office   
 	 dump.2.department( 	 bcstc018.aofd,   
 	  	  	  	 var.enum.accounting.office, bcstc018.entc,   
 	  	  	  	 bcstc018.lcmp, bcstc018.fcmp )   
 	  	  	  	  	  	  	  	 |#1843068.sn   
 	 |  *  Production Department   
 	 dump.2.department( 	 bcstc018.pddp,   
 	  	  	  	 var.enum.production.department,   
 	  	  	  	 bcstc018.entc,   
 	  	  	  	 bcstc018.lcmp, bcstc018.fcmp ) |#1843068.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select 	 bcstc018.*     
from 	 bcstc018
where 	 bcstc018.lcmp  =  :ext.lng.curr.comp 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:D
:QURY:START
	 |  *  get enterprise unit (bcstc018.entc)   
 	 ret.val  =  get.enterprise.unit( 	 tcmcs003.comp, 	 |  *  financial company   
 	  	  	  	  	 ext.lng.curr.comp, 	 |  *  log. company   
 	  	  	  	  	 tmp.errmess)   
 	    
 	 |  *  read cluster for warehouse   
 	 ret.val  =  get.cluster(ext.lng.curr.comp, tcmcs003.cwar, tmp.errmess)   
 	 if ret.val  <>  0 then   
 	  	 |  *  record not found; bcswh001.defw  =  0,   
 	  	 |  *  which is not OK for a yesno field   
 	  	 bcswh001.defw  =  tcyesno.no   
 	 endif   
 	  	    
 	 |  *  Insert a record in tcemm110 (Key Entities)   
 	 dump.1.key.entity( 	 tcmcs003.cwar,   
 	  	  	  	 ext.lng.curr.comp, 	    
 	  	  	  	 tcmcs003.comp, |  *  fin. comp.   
 	  	  	  	 var.enum.warehouse,   
 	  	  	  	 bcstc018.entc)   
 	    
 	 |  *  Insert a record in tcemm112 (Warehouse)   
 	 var.cwar  =  tcmcs003.cwar   
 	 dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:S
:QURY:START
select 	 tcmcs003.cwar, tcmcs003.comp   
from 	 tcmcs003
where 	 tcmcs003.typw  <>  tctypw.transito 	 |  *  see also tcmcs003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:X
:QURY:START
	  	  	  	  	  	    
 |  *  handle project warehouse. Assume that financial company  =  current company.   
 if not isspace(bcstp000.cwar) then   
 	 var.cwar  =  bcstp000.cwar(1; 6)   
 	 |  *  also assume that Enterprise Unit has been defined in bcstc018,   
 	 |  *  for this combination of log  /  fin company.   
 	 ret.val  =  get.enterprise.unit( 	 ext.lng.curr.comp, |  *  fin. comp   
 	  	  	  	  	 ext.lng.curr.comp, |  *  log. comp.   
 	  	  	  	  	 tmp.errmess)   
 	 |  *  read cluster for warehouse   
 	 ret.val  =  get.cluster(ext.lng.curr.comp, tcmcs003.cwar, tmp.errmess)   
 	    
 	 |  *  Insert a a record in tcemm110 (Key Entities)   
 	 dump.1.key.entity( 	 var.cwar,   
 	  	  	  	 ext.lng.curr.comp, 	    
 	  	  	  	 ext.lng.curr.comp, |  *  fin. comp.   
 	  	  	  	 var.enum.warehouse,   
 	  	  	  	 bcstc018.entc)   
 	    
 	 |  *  Insert a record in tcemm112 (Warehouse)   
 	 dump 3   
 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:D
:QURY:START
	 |  *  get enterprise unit (bcstc018.entc)   
 	 ret.val  =  get.enterprise.unit( 	 tirou001.ncmp, 	 |  *  financial company   
 	  	  	  	  	 ext.lng.curr.comp, 	 |  *  log. company   
 	  	  	  	  	 tmp.errmess)   
 	 |  *  Insert key Entity (tcemm110) and Departments (tcemm124)   
 	 dump.2.department( 	 tirou001.cwoc,   
 	  	  	  	 var.enum.workcenter,   
 	  	  	  	 bcstc018.entc,   
 	  	  	  	 ext.lng.curr.comp,   
 	  	  	  	 tirou001.ncmp )
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:S
:QURY:START
select tirou001.cwoc, tirou001.ncmp   
from tirou001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:D
:QURY:START
	 |  *  get enterprise unit (bcstc018.entc)   
 	 ret.val  =  get.enterprise.unit( 	 tppdm600.ncmp, 	 |  *  financial company   
 	  	  	  	  	 ext.lng.curr.comp, 	 |  *  log. company   
 	  	  	  	  	 tmp.errmess)   
 	 |  *  Insert a record in tcemm110 (Key Entities)   
 | 	 dump.1.key.entity(tppdm600.cprj, 	  	 |# 225130.o   
 	 dump.1.key.entity(get.tp.project(tppdm600.cprj), 	 |# 225130.n   
 	  	  	  	 ext.lng.curr.comp,   
 	  	  	  	 tppdm600.ncmp,   
 	  	  	  	 var.enum.project,   
 	  	  	  	 bcstc018.entc)   
 	 |  *  Insert Project in tcemm113 (Projects)   
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:S
:QURY:START
select tppdm600.cprj, tppdm600.ncmp   
from tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:emm
:TFLNO:110
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:mps
:SFLNO:200
:ICOD:D
:QURY:START
	  |   *  A plan item is for each master plan, so the same item code can exist   
 	  |   *  more than once.   
 	  |   *  Choose the most correct one by performing a search in this sequence:   
 	  |   *  1. actual plan code   
 	  |   *  2. multi site plan code of the actual plan code   
 	  |   *  3. any place   
 	  select timps200.*     
 	  from  	  timps200   
 	  where timps200._index3  =  {:timps000.apln, :timps200.plni}   
 	  as set with 1 rows   
 	  selectdo   
 	  selectempty   
 	   	  |   *  Search multi  -  site plan only when filled.   
 	   	  |   *  If empty go immediately to the last search step.   
 	   	  if not isspace(multi.site.plan.code) then   
 	   	   	  select timps200.*     
 	   	   	  from  	  timps200   
 	   	   	  where  	  timps200._index3  =  {  	  :multi.site.plan.code,   
 	   	   	   	   	   	   	  :timps200.plni}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  selectempty   
 	   	   	   	  select timps200.*     
 	   	   	   	  from  	  timps200   
 	   	   	   	  where timps200.plni  =  :timps200.plni   
 	   	   	   	  as set with 1 rows   
 	   	   	   	  selectdo   
 	   	   	   	  endselect   
 	   	   	  endselect   
 	   	  else   
 	   	   	  select timps200.*     
 	   	   	  from  	  timps200   
 	   	   	  where timps200.plni  =  :timps200.plni   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  endif   
 	  endselect   
 	  var.tcibd001.item  =  segment.item.code(timps200.plni,empty.string(1;9))   
 	  |   *  Dump for tcibd001 from timps200.   
 | 	  dump 24 |   *  tcibd001 from timps200  	  	  	  	 |#1920683.o   
 	  dump.tcibd001.from.timps200() 	  	  	  	  	  	 |#1920683.n   
 	  |   *  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   
 	  |   *  Dump for tcibd200 from timps200.   
 	  dump 25 |   *  tcibd200 from timps200
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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).   
 	 var.tcibd001.wpcs  =  tcyesno.yes 	 |  *  with PCS 	 |#10.5.2.sn   
 	 var.tcibd001.opol  =  tcyesno.yes 	 |  *  customize   
 	 var.tcibd001.osys  =  2 	  	 |  *  planned  	 |#10.5.2.en   
 	  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.*    	     
 	   	  from  	  tipcs150   
 	   	  where tipcs150._index1  =  {:tipcs002.cbdg,   
 	   	   	   	   	  :tipcs100.bccd, :tipcs002.ccpc}   
 	   	  selectdo   
 	   	   	  |   *  CNT  -  extension does not have tipcs150.amnt field. Therefor use   
 	   	   	  |   *  integration function to get the est. cost. price   
 	   	   	  get.tipcs150.ecpr(tmp.ecpr)   
 	     
 	   	   	  |   *  Add up for all cost components.   
 	   	   	  for element  =  1 to 3   
 	   	   	   	  var.ticpr007.ecpr(element)  =  var.ticpr007.ecpr(element)  +     
 	   	   	   	   	  tmp.ecpr(element)  	   	   	   	     
 	   	   	  endfor   
 	   	  endselect   
 	     
 	   	  |   *  Determine item type.   
 	   	  if (tipcs002.kitm  =  tcpuma.manufacture) then   
 	   	   	  var.tcibd001.kitm  =  etol(tckitm.manufacture)   
 	   	  else   
 	   	   	  var.tcibd001.kitm  =  etol(tckitm.purchase)   
 	   	  endif   
 	   	  get.aggr.cost.comp.for.item(   
 	   	   	   	  (tipcs002.kitm  =  tcpuma.manufacture  ?     
 	   	   	   	  tckitm.manufacture : tckitm.purchase),   
 	   	   	   	  tipcs002.citg,   
 	   	   	   	  tipcs002.cpcp,   
 	   	   	   	  var.ticpr007.acpm,   
 	   	   	   	  var.ticpr007.acpo,   
 	   	   	   	  var.ticpr007.acps)   
 	   	  |   *  Read cost component chart if present.   
 	   	  if get.cost.component.charts.per.item.type.and.group(   
 	   	   	   	  (tipcs002.kitm  =  tcpuma.manufacture  ?     
 	   	   	   	  tckitm.manufacture : tckitm.purchase),   
 	   	   	   	  tipcs002.citg,   
 	   	   	   	  error.message)  =  0 then   
 	   	   	  var.ticpr007.chrt  =  bcsti007.chrt   
 	   	  else   
 	   	   	  var.ticpr007.chrt  =  ""    
 	   	  endif   
 	   	  |   *  Dump for ticpr007 from tipcs002.   
 	   	  dump 20 |   *  ticpr007 from tipcs002   
 	   	     
 	   	  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   
 	   	  check.var.tiipd001.drin.bfcp()   
 	   	  |   *  Dump for tiipd001 from tipcs002.   
 	   	  dump 21 |   *  tiipd001 from tipcs002   
 	   	  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.   
 	   	  if isspace(tipcs002.cpvr) then  	   	   	   	   	     
 	   	   	  |# nor varian used then calling mapping function not needed.   
 	   	   	  bcsti002.cpva  =  0   
 	   	  else  	   	   	   	   	   	   	   	     
 	   	   	  return.value  =  get.product.variant.for.budget.item(   
 	   	   	   	   	   	  tipcs002.cbdg,   
 	   	   	   	   	   	  tipcs100.bccd,   
 	   	   	   	   	   	  tipcs002.cpvr,   
 	   	   	   	   	   	  error.message)   
 	   	  endif  	   	   	   	   	   	   	   	     
 	   	  |   *  Dump for tcibd001 from tipcs002.   
 | 	   	  dump 22 |   *  tcibd001 from tipcs002  	  	  	 |#1920683.o   
 	   	  dump.tcibd001.from.tipcs002() 	  	  	  	 |#1920683.n   
 	   	  |   *  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   
 	   	  |   *  Convert long to string.   
 	   	  var.tcibd200.cplb  =  format.emno(tipcs002.cplb)   
 	   	  |   *  Dump for tcibd200 from tipcs002.   
 	   	  dump 23 |   *  tcibd200 from tipcs002   
 	   	  |   *  Item Warehousing Data are also required.   
 	   	  |   *  Item Type  =  Equipment is not excluded, because   
 	   	  |   *  tipcs002 can never deliver this item type.   
 	   	  |   *  Dump for whwmd400 from tipcs002.   
 	   	  var.whwmd400.linv  =  tcyesno.no   
 | 	   	  dump 32 |   *  whwmd400 from tipcs002 	  	  	  	 |#1920683.o   
 	   	  dump.whwmd400.from.tipcs002() 	  	  	  	  	 |#1920683.n   
 	  selectempty   
 	   	  |   *  Construct new project code and new item code.   
 	   	  var.tcibd001.cprj  =  get.budget.code(tipcs002.cbdg, "")    
 	   	  var.tcibd001.item  =  segment.item.code(tipcs002.ccpc, var.tcibd001.cprj)   
 	   	  |   *  Determine item type.   
 	   	  if (tipcs002.kitm  =  tcpuma.manufacture) then   
 	   	   	  var.tcibd001.kitm  =  etol(tckitm.manufacture)   
 	   	  else   
 	   	   	  var.tcibd001.kitm  =  etol(tckitm.purchase)   
 	   	  endif   
 	   	  get.aggr.cost.comp.for.item(   
 	   	   	   	  (tipcs002.kitm  =  tcpuma.manufacture  ?     
 	   	   	   	  tckitm.manufacture : tckitm.purchase),   
 	   	   	   	  tipcs002.citg,   
 	   	   	   	  tipcs002.cpcp,   
 	   	   	   	  var.ticpr007.acpm,   
 	   	   	   	  var.ticpr007.acpo,   
 	   	   	   	  var.ticpr007.acps)   
 	   	  |   *  Read cost component chart if present.   
 	   	  if get.cost.component.charts.per.item.type.and.group(   
 	   	   	   	  (tipcs002.kitm  =  tcpuma.manufacture  ?     
 	   	   	   	  tckitm.manufacture : tckitm.purchase),   
 	   	   	   	  tipcs002.citg,   
 	   	   	   	  error.message)  =  0 then   
 	   	   	  var.ticpr007.chrt  =  bcsti007.chrt   
 	   	  else   
 	   	   	  var.ticpr007.chrt  =  ""    
 	   	  endif   
 	   	  |   *  Estimated cost price is always zero in this case.   
 	   	  for element  =  1 to 3   
 	   	   	  var.ticpr007.ecpr(element)  =  0.0   
 	   	  endfor   
 	   	  |   *  Dump for ticpr007 from tipcs002.   
 	   	  dump 20 |   *  ticpr007 from tipcs002   
 	   	  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   
 	   	  |   *  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   
 	   	  |   *  Dump for tiipd001 from tipcs002.   
 	   	  dump 21 |   *  tiipd001 from tipcs002   
 	   	  var.tcibd001.dfit  =  segment.item.code(tipcs002.dfit, empty.string(1;9))   
 	   	  |   *  Determine weigth unit.   
 	   	  determine.weight.unit(tipcs002.uset, var.tcibd001.cwun)   
 	   	  return.value  =  get.cost.components(   
 	   	   	   	   	  bcorig.ticpr,   
 	   	   	   	   	  tipcs002.cpcp,   
 	   	   	   	   	  "",    
 	   	   	   	   	  error.message)   
 	   	  var.tcibd001.cpcp  =  bcstc006.cost   
 	   	  |   *  Read product variant for this calculation part.   
 	   	  |   *  Use field bcsti002.cpva in field rule.   
 	   	  return.value  =  get.product.variant.for.budget.item(   
 	   	   	   	   	  tipcs002.cbdg,   
 	   	   	   	   	  "",    
 	   	   	   	   	  tipcs002.cpvr,   
 	   	   	   	   	  error.message)   
 	   	  |   *  Dump for tcibd001 from tipcs002.   
 | 	   	  dump 22 |   *  tcibd001 from tipcs002 	  	  	 |#1920683.o   
 	   	  dump.tcibd001.from.tipcs002() 	  	  	  	 |#1920683.n   
 	   	  |   *  Item Warehousing Data are also required.   
 	   	  |   *  Item Type  =  Equipment is not excluded, because   
 	   	  |   *  tipcs002 can never deliver this item type.   
 	   	  |   *  Dump for whwmd400 from tipcs002.   
 	   	  var.whwmd400.linv  =  tcyesno.no  	   	   	     
 | 	   	  dump 32 |   *  whwmd400 from tipcs002 	  	  	  	 |#1920683.o   
 	   	  dump.whwmd400.from.tipcs002() 	  	  	  	  	 |#1920683.n   
 	  endselect
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:ibd
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:D
:QURY:START
	 var.tcibd001.wpcs  =  tcyesno.yes 	 |  *  with PCS 	 |#10.5.2.sn   
 	 var.tcibd001.opol  =  tcyesno.yes 	 |  *  customize   
 	 var.tcibd001.osys  =  2 	  	 |  *  planned  	 |#10.5.2.en   
 	  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.   
 	  if isspace(tipcs021.cpvr) then  	   	   	   	   	     
 	   	  |# no producnt variant so no need to call mapping table.   
 	   	  bcsti001.cpvl  =  0   
 	  else  	   	   	   	   	   	   	   	     
 	   	  return.value  =  get.new.product.variant(   
 	   	   	   	   	  tipcs021.cpvr,   
 	   	   	   	   	  error.message)   
 	  endif  	   	   	   	   	   	   	   	     
 	  |   *  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))   
 	  |   *  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   
 	  |   *  Enum values for 'Update E  -  Item Relationship are changed.   
 	  on case tipcs021.umer   
 	  case tiitm.umer.yes :   
 	   	  var.tcibd001.umer  =  target(tcibd.umer.yes)   
 	   	  break   
 	  case tiitm.umer.freeze :   
 	   	  var.tcibd001.umer  =  target(tcibd.umer.freeze)   
 	   	  break  	   	   	   	   	   	     
 	  case tiitm.umer.break :   
 	   	  var.tcibd001.umer  =  target(tcibd.umer.break)  	     
 	   	  break   
 	  case tiitm.umer.not.appl :   
 	  default :   
 	   	  var.tcibd001.umer  =  target(tcibd.umer.not.appl)   
 	   	  break   
 	  endcase   
 	  |   *  In case the item will become serialized in 6.1,   
 	  |   *  it may need another inventory unit.   
 	  var.tcibd001.cuni  =  ""    
 	  if tipcs021.kltc  =  tckltc.unit then   
 	   	  var.tcibd001.cuni  =     
 	   	  get.new.inventory.unit.for.serialized.item(   
 	   	   	  tipcs021.cprj, tipcs021.item)   
 	  endif   
 	  |   *  If nothing found, fill with original inventory unit.   
 	  if isspace(var.tcibd001.cuni) then   
 	   	  var.tcibd001.cuni  =  tipcs021.cuni   
 	  endif   
 	  |   *  Dump for tcibd001 from tipcs021.   
 | 	  dump 8 |   *  tcibd001 from tipcs021  	  	  	  	 |#1920683.o   
 	  dump.tcibd001.from.tipcs021() 	  	  	  	  	  	 |#1920683.n   
 	  |   *  Determination of cost components is applicable for all   
 	  |   *  item types from tipcs021.   
 	  get.aggr.cost.comp.for.item(   
 	   	   	   	  (tipcs021.kitm  =  tcpuma.manufacture  ?     
 	   	   	   	  tckitm.manufacture : tckitm.purchase),   
 	   	   	   	  tipcs021.citg,   
 	   	   	   	  tipcs021.cpcp,   
 	   	   	   	  var.ticpr007.acpm,   
 	   	   	   	  var.ticpr007.acpo,   
 	   	   	   	  var.ticpr007.acps)   
 	  |   *  Read cost component chart if present.   
 	  if get.cost.component.charts.per.item.type.and.group(   
 	   	   	   	  (tipcs021.kitm  =  tcpuma.manufacture  ?     
 	   	   	   	  tckitm.manufacture : tckitm.purchase),   
 	   	   	   	  tipcs021.citg,   
 	   	   	   	  error.message)  =  0 then   
 	   	  var.ticpr007.chrt  =  bcsti007.chrt   
 	  else   
 	   	  var.ticpr007.chrt  =  ""    
 	  endif   
 	  var.ticpr007.ltcp  =  utc(tipcs021.ltcp, 0)   
 	  |   *  Fill Cost Price variables   
 	  for element  =  1 to 3   
 	   	  var.ticpr007.ecpr(element)  =  fill.mc.field.double(   
 	   	   	   	  tipcs021.cpre,   
 	   	   	   	  element,   
 	   	   	   	  0.0)  	     
 	   	  var.ticpr007.emtc(element)  =  fill.mc.field.double(   
 	   	   	   	  tipcs021.mtce,   
 	   	   	   	  element,   
 	   	   	   	  0.0)  	     
 	   	  var.ticpr007.eopc(element)  =  fill.mc.field.double(   
 	   	   	   	  tipcs021.opce,   
 	   	   	   	  element,   
 	   	   	   	  0.0)  	     
 	   	  var.ticpr007.acpr(element)  =  fill.mc.field.double(   
 	   	   	   	  tipcs021.cpra,   
 	   	   	   	  element,   
 	   	   	   	  0.0)  	     
 	   	  var.ticpr007.amtc(element)  =  fill.mc.field.double(   
 	   	   	   	  tipcs021.mtca,   
 	   	   	   	  element,   
 	   	   	   	  0.0)  	     
 	   	  var.ticpr007.aopc(element)  =  fill.mc.field.double(   
 	   	   	   	  tipcs021.opca,   
 	   	   	   	  element,   
 	   	   	   	  0.0)  	     
 	  endfor   
 	  |   *  Dump for ticpr007 from tipcs021.   
 	  dump 9 |   *  ticpr007 from tipcs021   
 	  if is.masterdata.conversion() then   
 	   	  |   *  In case only master data is migrated, the inventory   
 	   	  |   *  fields in tcibd100 need to be reset. Because in the   
 	   	  |   *  other situation most field rules are filled with table   
 	   	  |   *  fields and no special constructions, it is chosen here   
 	   	  |   *  to create a separate dump for master data migration.   
 	   	  |   *  Dump for tcibd100 from tipcs021 in case of   
 	   	  |   *  master data conversion.   
 | 	   	  dump 30 |   *  tcibd100 from tipcs021  	  	  |#tcibd100.o  	  	  	  	  	  	  	    
 	  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)   
 	   	  |   *  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   
 	   	  |   *  Dump for tcibd100 from tipcs021.   
 | 	   	  dump 10 |   *  tcibd100 from tipcs021  	  	 |#tcibd100.o   
 	  endif   
 	     
 	  |   *  Convert long to string.   
 	  var.tcibd200.cplb  =  format.emno(tipcs021.cplb)   
 	  |   *  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.   
 	  set.tcibd200.for.cust.items()  	     
 	  |   *  Dump for tcibd200 from tipcs021.   
 	  dump 11 |   *  tcibd200 from tipcs021   
 	     
 	  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   
 	  |   *  When item is lot controlled, Lot Tracking should get the   
 	  |   *  value of Lot Tracking Implemented (tdltc000.tltc).   
 	  if tipcs021.kltc  =  tckltc.batch then   
 	   	  var.whwmd400.lttr  =  tdltc000.tltc   
 	   	  var.whwmd400.linv  =  tcyesno.yes  	   	   	     
 	  else   
 	   	  var.whwmd400.lttr  =  tcyesno.no   
 	   	  var.whwmd400.linv  =  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 then   
 	   	  var.whwmd400.srtr  =  tdltc000.tltc   
 	   	  var.whwmd400.sinv  =  tcyesno.yes   
 	  else   
 	   	  var.whwmd400.srtr  =  tcyesno.no   
 	   	  var.whwmd400.sinv  =  tcyesno.no   
 	  endif   
 	  |   *  Dump for whwmd400 from tipcs021.   
 	  |   *  Item Type  =  Equipment is not excluded, because tipcs021 can   
 	  |   *  never deliver this item type.   
 | 	  dump 12 |   *  whwmd400 from tipcs021 	  	  	  	  	 |#1920683.o   
 	  dump.whwmd400.from.tipcs021() 	  	  	  	  	  	 |#1920683.n   
 	  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   
 	  else   
 	   	  var.tiipd001.drin  =  tcyesno.no   
 	  endif   
 	  |   *  Field tiipd001.dris can only be set to 'Yes' when   
 	  |   *  the item was a floor stock item in Baan IV, but   
 	  |   *  not serialized.   
 	  if tmp.floor.stock  =  tcyesno.yes and   
 	  not tipcs021.kltc  =  tckltc.unit then   
 	   	  var.tiipd001.dris  =  tcyesno.yes   
 	  else   
 	   	  var.tiipd001.dris  =  tcyesno.no   
 	  endif   
 	  |   *  Fields tiipd001.bfcp and tiipd001.drin cannot be 'Yes'   
 	  |   *  at the same time. Therefore tiipd001.bfcp is set to   
 	  |   *  'No' when tiipd001.drin is set to 'Yes'.   
 	  |   *  When the item becomes serialized in SSA ERP LN,   
 	  |   *  the backflush flag should also be set to 'No'.   
 	  if tmp.floor.stock  =  tcyesno.yes or   
 	  tipcs021.kltc  =  tckltc.unit then   
 	   	  var.tiipd001.bfcp  =  tcyesno.no   
 	  else   
 	   	  var.tiipd001.bfcp  =  tiitm001.bfcp   
 	  endif   
 	  check.var.tiipd001.drin.bfcp()   
 	  |   *  Dump for tiipd001 from tipcs021.   
 	  dump 13 |   *  tiipd001 from tipcs021   
 	  |   *  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   
 	   	   	   	  var.tppdm005.copt  =  tppdm.copt.manu   
 	   	   	  else   
 	   	   	   	  |   *  Select the Project Control Code   
 	   	   	   	  select  	  tppdm605.ppcs:ccit.ppcs,   
 	   	   	   	   	  tppdm605.citm:ccit.citm,   
 	   	   	   	   	  tppdm605.prit:ccit.prit   
 	   	   	   	  from  	  tppdm605   
 	   	   	   	  where  	  tppdm605._index1  =  {:tppdm605.cprj, :tppdm605.ccit}   
 	   	   	   	  as set with 1 rows   
 	   	   	   	  selectdo   
 	   	   	   	   	  |   *  If it exists and is manufactured, take the related PCS item   
 	   	   	   	   	  |   *  If it is purchased, take the TP item (ccit) itself   
 	   	   	   	   	  if ccit.prit  =  tppdm.prit.manufactured then   
 	   	   	   	   	   	  var.tppdm005.ccit.c  =  segment.item.code(ccit.citm, get.ti.project(ccit.ppcs))   
 	   	   	   	   	   	  var.tppdm005.copt  =  tppdm.copt.stock   
 	   	   	   	   	  else   
 	   	   	   	   	   	  var.tppdm005.ccit.c  =  segment.item.code(tppdm605.ccit, get.tp.project(tppdm605.cprj))   
 	   	   	   	   	   	  var.tppdm005.copt  =  tppdm.copt.manu   
 	   	   	   	   	  endif   
 	   	   	   	  selectempty   
 	   	   	   	   	  |   *  If it does not exist, take the empty Project code   
 	   	   	   	   	  var.tppdm005.ccit.c  =  segment.item.code(tppdm605.ccit, "")    
 	   	   	   	   	  var.tppdm005.copt  =  tppdm.copt.stock   
 	   	   	   	  endselect   
 	   	   	  endif   
 	   	   	   	   	     
 	   	   	  |   *  Dump for tppdm005 from tipcs021.   
 	   	   	  dump 29 |   *  tppdm005 from tipcs021   
 	   	  endselect   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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 may exist.
order by tipcs021._index1
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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  
 	   	   	  var.tppdm005.copt  =  tppdm.copt.manu  
 	   	  else  
 	   	   	  select  	  tppdm605.ppcs:ccit.ppcs,  
 	   	   	   	  tppdm605.citm:ccit.citm,  
 	   	   	   	  tppdm605.prit:ccit.prit  
 	   	   	  from  	  tppdm605  
 	   	   	  where  	  tppdm605._index1  =  {:tppdm605.cprj, :tppdm605.ccit}  
 	   	   	  as set with 1 rows  
 	   	   	  selectdo  
 	   	   	   	  |   *  If it exists and is manufactured, take the related PCS item  
 	   	   	   	  |   *  If it is purchased, take the TP item (ccit) itself  
 	   	   	   	  if ccit.prit  =  tppdm.prit.manufactured then  
 	   	   	   	   	  var.tppdm005.ccit.c  =  segment.item.code(ccit.citm, get.ti.project(ccit.ppcs))  
 	   	   	   	   	  var.tppdm005.copt  =  tppdm.copt.stock  
 	   	   	   	  else  
 	   	   	   	   	  var.tppdm005.ccit.c  =  segment.item.code(tppdm605.ccit, var.tcibd001.cprj)  
 	   	   	   	   	  var.tppdm005.copt  =  tppdm.copt.manu  
 	   	   	   	  endif  
 	   	   	  selectempty  
 	   	   	   	  |   *  If it does not exist, take the empty Project code  
 	   	   	   	  var.tppdm005.ccit.c  =  segment.item.code(tppdm605.ccit, "")  
 	   	   	   	  var.tppdm005.copt  =  tppdm.copt.stock  
 	   	   	  endselect  
 	   	  endif  
 	   	  |   *  Dump for tppdm005 from tppdm605.  
 	   	  dump 14 |   *  tppdm005 from tppdm605  
 	 	 if not isspace(tppdm000.whpi) then 	 |#LN1060.sn 	 |#REF error 2018 - 07 - 20.sn  
 	 	  	 var.tppdm007.cwar  =  tppdm000.whpi  
 	 	  	 dump 33 |  *  tppdm007 from tiitm001  
 	 	 endif 	  	  	  	  	 |#LN1060.en 	 |#REF error 2018 - 07 - 20.en  
 	  endif  
 	  |   *  Read bcstc006.  
 	  if isspace(tppdm605.ccco) then  
 	   	  bcstc006.cost  =  ""  
 	  else  
 	   	  return.value  =  get.cost.components (  
 	   	   	   	   	  bcorig.tppdm,  
 	   	   	   	   	  "",  
 	   	   	   	   	  tppdm605.ccco,  
 	   	   	   	   	  error.message)  
 	  endif  
 	  |   *  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 	 |#10.5.2.o  
 	  	  	  var.tcibd001.kitm  =  50 	  	 |#10.5.2.n  
 	   	  else  
 	   	   	  |   *  Subcontracting  
 | 	  	  	  var.tcibd001.kitm  =   	 6 	 |#10.5.2.o  
 	  	  	  var.tcibd001.kitm  =  60 	  	 |#10.5.2.n  
 	   	  endif  
 	  endif  
 	  |   *  Determine inventory and weigth unit.  
 	  equipment.item  =  left.align(tppdm605.item, 16)  
 	  equipment.item  =  right.align(equipment.item, 10)  
 	  subcontracting.item  =  left.align(tppdm605.item, 16)  
 	  subcontracting.item  =  right.align(subcontracting.item, 8)  
 	  if ( tppdm605.itmt  =  tppdm.itmt.item ) then  
 	   	  var.tcibd001.cuni  =  tppdm605.cuni  
 	   	  determine.weight.unit(tppdm605.uset, var.tcibd001.cwun)  
 	  endif  
 	  if ( tppdm605.itmt  =  tppdm.itmt.equipment ) then  
 	   	  select tppdm625.cuti  
 	   	  from  	  tppdm625  
 	   	  where tppdm625._index1  =  {:tppdm605.cprj, :equipment.item}  
 	   	  as set with 1 rows  
 	   	  selectdo  
 	   	   	  var.tcibd001.cuni  =  tppdm625.cuti  
 	   	   	  var.tcibd001.cwun(1;3)  =  ""  
 	   	  endselect  
 	  endif  
 	  if (tppdm605.itmt  =  tppdm.itmt.subcontracting) then  
 	   	  select tppdm635.cuti, tppdm635.dsbc, tppdm635.cuni  
 	   	  from tppdm635  
 	   	  where tppdm635._index1  =  {:tppdm605.cprj, :subcontracting.item}  
 	   	  as set with 1 rows  
 	   	  selectdo  
 	   	   	  var.tcibd001.cwun(1;3)  =  ""  
 	   	   	  if ( tppdm635.dsbc  =  tppdm.dsbc.quantity) then  
 	   	   	   	  var.tcibd001.cuni  =  tppdm635.cuni  
 	   	   	  else  
 	   	   	   	  var.tcibd001.cuni  =  tppdm635.cuti  
 	   	   	  endif  
 	   	  endselect  
 	  endif  
 	  var.tcibd001.seab  =  var.tcibd001.item(1;16)  
 	  |   *  Dump for tcibd001 from tppdm605.  
 | 	  dump 15 |   *  tcibd001 from tppdm605  	  	  	  	 |#1920683.o  
 	  dump.tcibd001.from.tppdm605() 	  	  	  	  	  	 |#1920683.n  
 	  |   *  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  
 	   	   	   	   	   	   	   	  |# 1549733.sn  
 	   	  if item.is.plan.item(tppdm605.item, tppdm605.cprj) then  
 	   	   	   	  var.tcibd200.osys  =  2  
 	   	   	   	  |   *  Order System is Planned  
 	   	  endif  
 	   	   	   	   	   	   	   	  |# 1549733.en  
 	  endif  
 	  |   *  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  
 	  |   *  Dump for tcibd200 from tppdm605.  
 	  dump 17 |   *  tcibd200 from tppdm605  
 | 	 if not isspace(tppdm000.whpi) then 	 |#LN1060.sn 	 |#REF error 2018 - 07 - 20.so  
 | 	  	 var.tppdm007.cwar  =  tppdm000.whpi  
 | 	  	 dump 33 |  *  tppdm007 from tiitm001  
 | 	 endif 	  	  	  	  	 |#LN1060.en 	 |#REF error 2018 - 07 - 20.eo  
 	  |   *  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  
 	   	  |   *  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  
 	   	  |   *  Dump for ticpr007 from tppdm605.  
 	   	  dump 18 |   *  ticpr007 from tppdm605  
 	  endif  
 	  |   *  Do not dump to whwmd400 when Item Type  =  Equipment.  
 	  if tppdm605.itmt  <>  tppdm.itmt.equipment then  
 	   	  |   *  Outbound methods Fifo or Lifo are only allowed when  
 	   	  |   *  item type is purchased, manufactured or generic.  
 	   	  if var.tcibd001.kitm  =  1 or |   *  tckitm.purchased  
 	   	  var.tcibd001.kitm  =  2 or |   *  tckitm.manufactured  
 	   	  var.tcibd001.kitm  =  3 then |   *  tckitm.generic  
 	   	   	  var.whwmd400.obpr  =  tcobpr.fifo  
 	   	  else  
 	   	   	  var.whwmd400.obpr  =  tcobpr.loca  
 	   	  endif  
 	   	  var.whwmd400.linv  =  tcyesno.no  
 	   	  |   *  Dump for whwmd400 from tppdm605.  
 | 	   	  dump 19 |   *  whwmd400 from tppdm605 	  	  	  	 |#1620683.o  
 	   	  dump.whwmd400.from.tppdm605()  	  	  	  	  	 |#1620683.n  
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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 |#DF503120.o
order by tppdm605._index1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  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   
 	  dump 8  	  |   *  Dump for ticpr008 from bcstc010.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:ibd
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:D
:QURY:START
	  |  *  When Order System  =  MRP in Baan IV, convert to |#10.5.2.en   
 	  |  *  Planned in Baan 6.0.   
 	  if (tiitm002.osys  =  tcosys.mrp) then   
 	   	  var.tcibd201.osys  =  2   
 	  else   
 	   	  var.tcibd201.osys  =  etol(tiitm002.osys)   
 	  endif  	  	  	  	  	  	  	 |#10.5.2.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   
 	  |   *  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   
 	  if tiitm002.kltc  =  tckltc.batch then   
 	   	  var.whwmd401.linv  =  tcyesno.yes   
 	  else   
 	   	  var.whwmd401.linv  =  tcyesno.no   
 	  endif   
 	  if tiitm002.kltc  =  tckltc.unit then   
 	   	  var.whwmd401.sinv  =  tcyesno.yes   
 	  else   
 	   	  var.whwmd401.sinv  =  tcyesno.no   
 	  endif   
 	  if var.whwmd401.linv  =  tcyesno.yes and  	   	  |# FP5.sn   
 	  (tiitm002.kitm  =  tckitm.purchase or   
 	  tiitm002.kitm  =  tckitm.manufacture or   
 	  tiitm002.kitm  =  tckitm.generic) then   
 	   	  var.whwmd401.lism  =  target(tcynna.no)   
 	  else   
 	   	  var.whwmd401.lism  =  target(tcynna.not.app)   
 	  endif  	   	   	   	   	   	   	  |# FP5.en   
 	  dump 1 |   *  Dump for whwmd401.   
 	  if tiitm002.kitm  <>  tckitm.subcontracting then   
 	  |   *  No Project Default Data for Item Type  ==  Subcontracting.   
 	   	  dump 2 |   *  Dump for tppdm006.   
 	   	  if not isspace(tiitm002.cwar) then 	  	 |#tppdm008.sn   
 	  	  	 dump 9 |   *  Dump for tppdm008 from tiitm002.   
 	   	  endif 	  	  	  	  	  	 |#tppdm008.en   
 	  endif   
 	  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   
 	   	  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   
 	   	  dump 3 |   *  Dump for tiipd002.   
 	  endif   
 	  |   *  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   
 	   	  |   *  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)   
 	  	  	  	  	  	  	  	 |#10.5.2.so   
 | 	   	  |   *  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  	  	  	  	  	  	 |#10.5.2.eo   
 	   	  |   *  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   
 	   	   	   	   	   	   	   	  |# FP10.sn   
 	   	  var.tcibd201.wpcs  =  determine.tcibd201.wpcs(   
 	   	   	   	   	   	   	  tiitm002.kitm,   
 	   	   	   	   	   	   	  tiitm002.opol)   
 	   	   	   	   	   	   	   	  |# FP10.en   
 	   	  dump 4 |   *  Dump for tcibd201.   
 	  endif   
 	  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   
 	   	  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   
 	   	  dump 5 |   *  Dump for ticpr008.   
 	  endif   
 	  if (not isspace(tiitm002.ccco)) then   
 	   	  |   *  Read bcstc006 for tppdm cost component type.   
 	   	  return.value  =  get.cost.components(   
 	   	   	   	   	  bcorig.tppdm,   
 	   	   	   	   	  "",   
 	   	   	   	   	  tiitm002.ccco,   
 	   	   	   	   	  error.message)   
 	   	  var.tcibd002.cpcp  =  bcstc006.cost   
 	  else   
 	   	  |   *  Read bcstc006 for ticpr cost component type.   
 	   	  return.value  =  get.cost.components(   
 	   	   	   	   	  bcorig.ticpr,   
 	   	   	   	   	  tiitm002.cpcp,   
 	   	   	   	   	  "",   
 	   	   	   	   	  error.message)   
 	   	  |   *  Field bcstc006.cost is empty when record not found.   
 	   	  if not isspace(bcstc006.cost) then   
 	   	   	  var.tcibd002.cpcp  =  bcstc006.cost   
 	   	  else   
 	   	   	  |   *  Field tcibd002.cpcp is mandatory for cost and service items.   
 	   	   	  |   *  So fill with default material cost component when other   
 	   	   	  |   *  sources do not contain data.   
 	   	   	  if tiitm002.kitm  =  tckitm.cost or   
 	   	   	  tiitm002.kitm  =  tckitm.service then   
 	   	   	   	  var.tcibd002.cpcp  =  bcstc000.matc   
 	   	   	  else   
 	   	   	   	  var.tcibd002.cpcp  =  empty.string(1;8)   
 	   	   	  endif   
 	   	  endif   
 	  endif   
 	   	   	   	   	   	   	   	  |# 214022.sn   
 |   *  Migrate subentity  -  fields based on function tcibd0003.handle.ui.entities()   
 |   *  NOTE: based on the real coding, the matrix is adjusted  !!    
 |   *    	  (compared to# include tcibd0003)   
 |   *    
 |   *    	  The next matrix shows the current situation:   
 |   *    	  1: enabled   
 |   *    	  0: disabled   
 |   *    
 |   *  type | sald | prod | cosd | ward | prtd | purd | ordd | plnd | serd | fmgd | Cnfg   
 |   *-----------------------------------------------------------------------------    
 |   *  COST | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 0   
 |   *  SERV | 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0   
 |   *  SUBC | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0   
 |   *  GEN | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1   
 |   *  LIST | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0   
 |   *  EQUIP | 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0   
 |   *  MANUF | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0   
 |   *  PURCH | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0   
 |   *  ENG_M | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0   
 |   *-----------------------------------------------------------------------------    
 	  var.tcibd002.sald  =  1 |   *  Yes   
 	  var.tcibd002.prod  =  1 |   *  Yes   
 	  var.tcibd002.cosd  =  1 |   *  Yes   
 	  var.tcibd002.ward  =  1 |   *  Yes   
 	  var.tcibd002.prtd  =  1 |   *  Yes   
 	  var.tcibd002.purd  =  1 |   *  Yes   
 	  var.tcibd002.ordd  =  1 |   *  Yes   
 |  	  if (tiitm002.osys  =  tcosys.mrp) or  	   	   	  |# 246288.so   
 |  	  (tiitm002.osys  =  tcosys.mps) then   
 |  	   	  var.tcibd002.plnd  =  1 |   *  tcyesno.yes   
 |  	  else   
 |  	   	  var.tcibd002.plnd  =  2 |   *  tcyesno.no   
 |  	  endif  	   	   	   	   	   	   	  |# 246288.eo   
 	  if tiitm002.kitm  =  tckitm.purchase or  	   	  |# 246288.sn   
 	  tiitm002.kitm  =  tckitm.manufacture or   
 	  tiitm002.kitm  =  tckitm.generic then   
 | 	  |# used same construction as for dump 7 cprpd101   
 	   	  var.tcibd002.plnd  =  1 |   *  tcyesno.yes   
 	  else   
 	   	  var.tcibd002.plnd  =  2 |   *  tcyesno.no   
 	  endif  	   	   	   	   	   	   	  |# 246288.en   
 	  var.tcibd002.serd  =  1 |   *  Yes   
 	  var.tcibd002.fmgd  =  1 |   *  Yes   
 	  var.tcibd002.cnfg  =  2 |  	    *  No  	   	   	  |# 1544270.n   
 	  on case tiitm002.kitm   
 	  case tckitm.purchase  	  :   
 	   	  break   
 	  case tckitm.manufacture  	  :   
 	   	  break   
 	  case tckitm.generic  	  :   
 	   	  var.tcibd002.serd  =  2 |   *  No  	   	  |# 1064971.n   
 	   	  var.tcibd002.cnfg  =  1 |   *  Yes  	   	  |# 1544270.n   
 	   	  break   
 	  case tckitm.cost  	  :   
 	   	  var.tcibd002.prod  =  2 |   *  No   
 	   	  var.tcibd002.ordd  =  2 |   *  No   
 	   	  var.tcibd002.plnd  =  2 |   *  No   
 	   	  break   
 	  case tckitm.service  	  :   
 	   	  var.tcibd002.prod  =  2 |   *  No   
 	   	  var.tcibd002.plnd  =  2 |   *  No   
 	   	  var.tcibd002.fmgd  =  2 |   *  No   
 	   	  break   
 	  case tckitm.subcontracting  	  :   
 	   	  var.tcibd002.sald  =  2 |   *  No   
 	   	  var.tcibd002.prod  =  2 |   *  No   
 	   	  var.tcibd002.cosd  =  2 |   *  No   
 	   	  var.tcibd002.prtd  =  2 |   *  No   
 	   	  var.tcibd002.ordd  =  2 |   *  No   
 	   	  var.tcibd002.plnd  =  2 |   *  No   
 	   	  var.tcibd002.serd  =  2 |   *  No   
 	   	  var.tcibd002.fmgd  =  2 |   *  No   
 	   	  break   
 	  default: break   
 	  endcase   
 |# 235711.sn   
 	  current.comp  =  get.compnr()   
 	  select tccom999.trtr   
 	  from  	  tccom999   
 	  where  	  tccom999._compnr  =  :current.comp   
 	  selectdo   
 	   	  |# in the above case statement the variable var.tcibd002.fmgd   
 	   	  |# is set. owever this parameter is always set to "No" if   
 	   	  |# transportation is not implemented at the source.   
 	   	  if tccom999.trtr  =  tcyesno.no then   
 	   	   	  var.tcibd002.fmgd  =  target(tcyesno.no)   
 	   	  endif   
 	  endselect   
 |# 235711.en   
 	  |   *  Determine Lot Control yes  /  no and Serialized yes  /  no.   
 	  on case tiitm002.kltc   
 	  case tckltc.batch:   
 	   	  var.tcibd002.ltct  =  tcyesno.yes   
 	   	  var.tcibd002.seri  =  tcyesno.no   
 	  break   
 	  case tckltc.unit:   
 	   	  var.tcibd002.ltct  =  tcyesno.no   
 	   	  var.tcibd002.seri  =  tcyesno.yes   
 	  break   
 	  case tckltc.none:   
 	  default:   
 	   	  var.tcibd002.ltct  =  tcyesno.no   
 	   	  var.tcibd002.seri  =  tcyesno.no   
 	  break   
 	  endcase   
 	  if tiitm002.kitm  =  tckitm.cost then   
 	  endif   
 	  dump 6 |   *  Dump for tcibd002.   
 	  |   *  Dump for cprpd101. But not for all item types...   
 	  if tiitm002.kitm  =  tckitm.purchase or   
 	  tiitm002.kitm  =  tckitm.manufacture or   
 	  tiitm002.kitm  =  tckitm.generic then   
 	   	  dump 7 |   *  Dump for cprpd101. But not for all item types...   
 	  endif
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:003
:SCPAC:tc
:SCMOD:mcs
:SFLNO:003
:ICOD:D
:QURY:START
	  var.tcmcs003.cwar  =  tcmcs003.cwar(1; 3)   
 	  result  =  get.addresses( "tcmcs003",    
 	   	   	   	  var.tcmcs003.cwar,   
 	   	   	   	  dummy.err.mess)   
 	  if tcmcs003.typw  =  tctypw.wip then 	  	  	 |#LN10.5.sn   
 	   	 var.tcmcs003.swhu  =  target(tcswhu.work.center)   
 	  else   
 	   	 var.tcmcs003.swhu  =  target(tcswhu.not.appl)   
 	  endif 	  	  	  	  	  	 |#LN10.5.sn   
 	  dump 1 |   *  Warehouses (tcmcs003)   
 	  if tcmcs003.sloc  =  tcyesno.yes then   
 	   	  var.whwmd200.stlo  =  bcswh000.sloc   
 	   	  var.whwmd200.ialt  =  5 |   *  whwmd.loct.bulk   
 	   	  var.whwmd200.uolo  =  tdilc000.uolo  	   	  |# 222436.n   
 	   	  var.whwmd200.frlo  =  tdilc000.frlo  	   	  |# 222436.n   
 	  else   
 	   	  var.whwmd200.stlo  =  string.set$(" ",10)   
 	   	  var.whwmd200.ialt  =  20 |   *  whwmd.loct.not.appl   
 	   	  var.whwmd200.uolo  =  tcyesno.no  	   	   	  |# 222436.n   
 	   	  var.whwmd200.frlo  =  tcyesno.no  	   	   	  |# 222436.n   
 	  endif   
 	  if get.enterprise.unit(  	  tcmcs003.comp,   
 	   	   	   	  l.logistic.company,   
 	   	   	   	  dummy.err.mess)  =  0 then   
 	   	  var.whwmd200.wvgr  =  bcstc018.entc   
 	  else   
 	   	  var.whwmd200.wvgr  =  string.set$(" ",6)   
 	  endif   
 	  if tcmcs003.typw  =  tctypw.wip then 	   	   	 |# FP10.sn   
 	   	  var.whwmd200.uidt  =  tcyesno.no   
 	  else   
 	   	  var.whwmd200.uidt  =  tcyesno.yes   
 	  endif  	   	   	   	   	   	 |# FP10.en   
 	  dump 2 |   *  Warehouses (whwmd200)
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:023
:SCPAC:tc
:SCMOD:mcs
:SFLNO:023
:ICOD:D
:QURY:START
	 if not isspace(tfacp000.cost) and   
 	 tfacp000.cost  =  tcmcs023.citg then   
 	  	 var.tcmcs023.spec  =  tcyesno.yes   
 	 else   
 	  	 var.tcmcs023.spec  =  tcyesno.no   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:023
:SCPAC:tc
:SCMOD:mcs
:SFLNO:023
:ICOD:S
:QURY:START
select 	 tcmcs023.citg,tcmcs023.dsca  
from 	 tcmcs023
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:023
:SCPAC:tc
:SCMOD:mcs
:SFLNO:023
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	     
 	  var.tcmcs036.appr  =  bcstc030.appr  	   	  |# 217144.n   
 	  dump 1   
 	  if tcmcs036.smpl  =  tcyesno.yes then  	   	  |# 209288.n   
 	   	  dump 2   
 	  endif  	   	   	   	   	   	  |# 209288.n
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:bc
:SCMOD:sti
:SFLNO:012
:ICOD:D
:QURY:START
	 |*  Insert the four aggregated and four   
 	 |*  collect cost components   
 	 var.tcmcs048.dsca  =  "Migrated Aggregated Cost Comp."   
 	 var.tcmcs048.cpcp  =  bcsti012.aggm   
 	 var.tcmcs048.cref  =  2 |material   
 	 var.tcmcs048.cpus  =  30 |aggregated   
 	 var.tcmcs048.iinv  =  2 |no   
 	 var.tcmcs048.fxvc  =  100 | not applicable   
 	 var.tcmcs048.dinc  =  100 | not applicable   
 	 var.tcmcs048.tpoc  =  100 | not applicable   
 	    
 	 dump 3 |tcmcs048   
 	    
 	 var.tcmcs048.cpcp  =  bcsti012.aggo   
 	 var.tcmcs048.cref  =  1 |operation   
 	 var.tcmcs048.cpus  =  30 |aggregated   
 	 var.tcmcs048.iinv  =  2 |no   
 	 var.tcmcs048.fxvc  =  100 | not applicable   
 	 var.tcmcs048.dinc  =  100 | not applicable   
 	 var.tcmcs048.tpoc  =  50 |  !  not specified   
 	    
 	 dump 3 |tcmcs048   
 	    
 	 var.tcmcs048.cpcp  =  bcsti012.aggs   
 	 var.tcmcs048.cref  =  4 |surcharge   
 	 var.tcmcs048.cpus  =  30 |aggregated   
 	 var.tcmcs048.iinv  =  2 |no   
 	 var.tcmcs048.fxvc  =  100 | not applicable   
 	 var.tcmcs048.dinc  =  100 | not applicable   
 	 var.tcmcs048.tpoc  =  100 | not applicable   
 	 dump 3 |tcmcs048   
 	 var.tcmcs048.cpcp  =  bcsti012.aggg   
 	 var.tcmcs048.cref  =  6 |general   
 	 var.tcmcs048.cpus  =  30 |aggregated   
 	 var.tcmcs048.iinv  =  2 |no   
 	 var.tcmcs048.fxvc  =  100 | not applicable   
 	 var.tcmcs048.dinc  =  100 | not applicable   
 	 var.tcmcs048.tpoc  =  100 | not applicable   
 	 dump 3 |tcmcs048   
 	 var.tcmcs048.dsca  =  "Migrated Collect Cost Comp."   
 	    
 	 var.tcmcs048.cpcp  =  bcsti012.colm   
 	 var.tcmcs048.cref  =  2 |material   
 	 var.tcmcs048.cpus  =  20|collect   
 	 var.tcmcs048.iinv  =  1 |yes   
 	 var.tcmcs048.fxvc  =  30 | both   
 	 var.tcmcs048.dinc  =  10 | direct   
 	 var.tcmcs048.tpoc  =  100 | not applicable   
 	    
 	 dump 3 |tcmcs048   
 	    
 	 var.tcmcs048.cpcp  =  bcsti012.colo   
 	 var.tcmcs048.cref  =  1 |operation   
 	 var.tcmcs048.cpus  =  20|collect   
 	 var.tcmcs048.iinv  =  1 | yes   
 	 var.tcmcs048.fxvc  =  30 | both   
 	 var.tcmcs048.dinc  =  10 | direct   
 	 var.tcmcs048.tpoc  =  50 | not specified   
 	 dump 3 |tcmcs048   
 	    
 	 var.tcmcs048.cpcp  =  bcsti012.cols   
 	 var.tcmcs048.cref  =  4 |surcharge   
 	 var.tcmcs048.cpus  =  20|collect   
 	 var.tcmcs048.iinv  =  1 |yes   
 	 var.tcmcs048.fxvc  =  30 | both   
 	 var.tcmcs048.dinc  =  20 | indirect   
 	 var.tcmcs048.tpoc  =  100 | not applicable   
 	 dump 3 |tcmcs048   
 	    
 	 var.tcmcs048.cpcp  =  bcsti012.colg   
 	 var.tcmcs048.cref  =  6 |general   
 	 var.tcmcs048.cpus  =  20 |collect   
 	 var.tcmcs048.iinv  =  1 |yes   
 	 var.tcmcs048.fxvc  =  30 | both   
 	 var.tcmcs048.dinc  =  10 | direct   
 	 var.tcmcs048.tpoc  =  100 | not applicable   
 	 dump 3 |tcmcs048   
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:bc
:SCMOD:sti
:SFLNO:012
:ICOD:S
:QURY:START
select bcsti012.*  |*  default agg. and collect cost components |#10.6.sn   
from bcsti012
where bcsti012._index1  =  {1}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:bc
:SCMOD:sti
:SFLNO:012
:ICOD:X
:QURY:START
	  	  	  	  	  	  	 |#10.6.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:ti
:SCMOD:cpr
:SFLNO:010
:ICOD:D
:QURY:START
	 if bcstc006.coll  =  tcyesno.yes then 	  	  	 |#2041865.sn   
 	  	 var.tcmcs048.cpus  =  target(tccpus.collect)   
 	 else   
 	  	 var.tcmcs048.cpus  =  target(tccpus.detail)   
 	 endif 	  	  	  	  	  	  	 |#2041865.en   
 	 var.tcmcs048.cref  =  determine.cost.type(bcstc006.cref)   
 	 var.tcmcs048.tpoc  =  determine.cost.sub.type(bcstc006.cref) |#10.5.1.n   
 	 dump 1 |tcmcs048
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:ti
:SCMOD:cpr
:SFLNO:010
:ICOD:S
:QURY:START
select 	  	 ticpr010.dsca, bcstc006.cost, bcstc006.cref,   
 	  	 bcstc006.coll   
from 	 ticpr010, bcstc006
where 	 bcstc006._index1  =  {bcorig.ticpr, ticpr010.cpcp}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:ti
:SCMOD:cpr
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:tp
:SCMOD:pdm
:SFLNO:100
:ICOD:D
:QURY:START
	 var.tcmcs048.cref  =  determine.cost.type(bcstc006.cref) |# 222469.n   
 	 var.tcmcs048.tpoc  =  determine.cost.sub.type(bcstc006.cref) 	 |#10.5.1.n   
 	 dump 2 |tcmcs048
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:tp
:SCMOD:pdm
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tppdm100.*  , bcstc006.cost, bcstc006.cref 	 |# 222469.n   
from 	 tppdm100, bcstc006
where 	 bcstc006._index1  =  {bcorig.tppdm, "", tppdm100.ccco}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:048
:SCPAC:tp
:SCMOD:pdm
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:052
:SCPAC:bc
:SCMOD:stc
:SFLNO:016
:ICOD:D
:QURY:START
	   var.tcmcs052.seak  =  strip$(bcstc016.dsca(1; 16))   
 	   var.tcmcs052.seab  =  strip$(bcstc016.dscb(1; 16))   
 	   if bcstc016.oprj  =  bcstc.oprj.budget or   
 	   bcstc016.oprj  =  bcstc.oprj.ti.project then   
 	     	   var.tcmcs052.plnk  =  20   
 	   else   
 	     	   var.tcmcs052.plnk  =  30   
 	   endif   
 	    |    *  determine (new) project code.   
 	   if bcstc000.ucpr  =  tcyesno.no then   
 	     	    |    *  no duplicates in the project codes at BaanIV   
 	     	   var.nprj  =  bcstc016.ocod  |    *  for tp and ti projects   
 	     	   if bcstc016.oprj  =  bcstc.oprj.budget then   
 	     	     	   var.nprj  =  bcstc016.nprj  |    *  for Budgets always new code   
 	     	   endif   
 	   else   
 	     	   var.nprj  =  bcstc016.nprj   
 	   endif   
 	   dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:055
:SCPAC:tc
:SCMOD:mcs
:SFLNO:055
:ICOD:D
:QURY:START
	  determine.var.tcmcs055.pitm(tcmcs055.cprl)   
 	  determine.var.tcmcs055.pitd(tcmcs055.cprl)   
 	  determine.var.tcmcs055.csot(tcmcs055.ccin)   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:065
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:D
:QURY:START
	 var.tcmcs065.cwoc  =  bcstc018.sofd   
 	 var.tcmcs065.dsca  =  bcstc018.sdsc   
 	 var.tcmcs065.typd  =  target(tctypd.sls.office)   
 	 |  *  Sales Office   
 	 Dump 2   
 	 var.tcmcs065.cwoc  =  bcstc018.pofd   
 	 var.tcmcs065.dsca  =  bcstc018.pdsc   
 	 var.tcmcs065.typd  =  target(tctypd.pur.office)   
 	 |  *  Purchase Office   
 	 Dump 2   
 	 var.tcmcs065.cwoc  =  bcstc018.srfd   
 	 var.tcmcs065.dsca  =  bcstc018.rdsc   
 	 var.tcmcs065.typd  =  target(tctypd.service.dept)   
 	 |  *  Service Department   
 	 Dump 2   
 	 |  *  Work Center is a regular Baan IV tirou001 work center   
 	 |  *  it is dumped via 'migrate tirou001'   
 | 	 var.tcmcs065.cwoc  =  bcstc018.wccd   
 | 	 var.tcmcs065.dsca  =  bcstc018.wdsc   
 | 	 var.tcmcs065.typd  =  target(tctypd.workcentre)   
 | 	 |  *  Work Center   
 | 	 Dump 2   
 	 var.tcmcs065.cwoc  =  bcstc018.shod   
 	 var.tcmcs065.dsca  =  bcstc018.hdsc   
 	 var.tcmcs065.typd  =  target(tctypd.shipping.office)   
 	 |  *  Shipping Office   
 	 Dump 2   
 	 var.tcmcs065.cwoc  =  bcstc018.aofd   
 	 var.tcmcs065.dsca  =  bcstc018.adsc   
 	 var.tcmcs065.typd  =  target(tctypd.accounting)   
 	 Dump 2   
 	  	  	  	  	  	  	  	 |#1843068.sn   
 	 var.tcmcs065.cwoc  =  bcstc018.pddp   
 	 var.tcmcs065.dsca  =  bcstc018.pddd   
 	 var.tcmcs065.ccal  =  bcstc000.cccd   
 	 var.tcmcs065.ract  =  bcstc000.ract   
 	 var.tcmcs065.typd  =  target(tctypd.production.dept)   
 	 Dump 2   
 	  	  	  	  	  	  	  	 |#1843068.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:065
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select 	 bcstc018.*     
from 	 bcstc018
where 	 bcstc018.lcmp  =  :current.comp
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:065
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:065
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:D
:QURY:START
	 select 	 tirou400.cwoc:dummy.cwoc   
 	 from 	 tirou400   
 	 where 	 tirou400._index1  =  {:tirou001.cwoc}   
 	 as set with 1 rows   
 	 selectdo   
 	  	 if tirou001.cwoc  =  "ZZZ" then   
 	  	  	 var.tcmcs065.ccal  =  bcstc000.cccd   
 	  	  	 var.tcmcs065.ract  =  bcstc000.ract  	 |#LN10.4.1.1.n   
 	  	 else   
 	  	  	 var.tcmcs065.ccal  =  strip$(shiftl$(bcstc000.wccp))  &  left.align (tirou001.cwoc,3)   
 	  	  	 var.tcmcs065.ract  =  bcstc000.ract  	 |#LN10.4.1.1.n   
 	  	 endif   
 	 selectempty   
 	  	 var.tcmcs065.ccal  =  ""   
 	  	 var.tcmcs065.ract  =  "" 	  	  	 |#LN10.4.1.1.n   
 	 endselect   
 	 Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:065
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tirou001.cwoc, tirou001.dsca, tirou001.ncmp   
from 	 tirou001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:065
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:210
:SCPAC:bc
:SCMOD:std
:SFLNO:003
:ICOD:D
:QURY:START
	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:210
:SCPAC:bc
:SCMOD:std
:SFLNO:003
:ICOD:S
:QURY:START
select  	  bcstd003.*     
from 	  bcstd003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:210
:SCPAC:bc
:SCMOD:std
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:ppl
:TFLNO:010
:SCPAC:bc
:SCMOD:sbp
:SFLNO:001
:ICOD:D
:QURY:START
	 if s.new.skill  =  bcsbp001.nskl then   
 	  	 continue   
 	 endif   
 	 s.new.skill  =  bcsbp001.nskl   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:ppl
:TFLNO:010
:SCPAC:bc
:SCMOD:sbp
:SFLNO:001
:ICOD:S
:QURY:START
select 	 bcsbp001.*   
from 	 bcsbp001
order by bcsbp001._index2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:ppl
:TFLNO:010
:SCPAC:bc
:SCMOD:sbp
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:S
:QURY:START
select  	  tiitm001.*     
from 	  tiitm001   
 |   *  nvdknaap, 20110307: taken from tcibd001 migration logic  	   	  |   *  FP7  +  .sn   
 |   *  Process items (tiitm001.proi  =  tcyesno.yes) are migrated, but not   
 |   *  the container items (tiitm001.cont  =  tcyesno.yes).
where 	  tiitm001.cont  =  tcyesno.no  	   	   	   	   	  |   *  FP7  +  .en
:QURY:END
:TEXT:

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:S
:QURY:START
select  	  tipcs021.*  ,   
 	   	  tiitm001.cpgp,   
 	   	  tiitm001.kitm  	   	   	   	   	  |# FP10.n   
from 	  tipcs021, tiitm001,   
 	  tipcs020  	   	   	   	   	   	  |# FP7  +  .n
where 	  tipcs021.dfit refers to tiitm001 unref clear   
 | and not exists(  	   	   	   	   	   	  |# FP7  +  .so   
 |  	   	  select tppdm605.item   
 |  	   	  from  	  tppdm605   
 |  	   	  where tppdm605._index1  =  {   
 |  	   	   	   	   	  tipcs021.cprj,   
 |  	   	   	   	   	  tipcs021.item})  	  |# FP7  +  .eo   
 and  	  tipcs020._index1  =  {tipcs021.cprj}  	   	   	  |# FP7  +  .sn   
 and  	  tipcs020.prtp  <>  tcyesno.yes  	     
 |   *  Do not include customized items from tppdm605,   
 |   *  duplicate project  &  item codes can exist.   
 	   	   	   	   	   	   	   	  |# FP7  +  .en
:QURY:END
:TEXT:

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:001
:SCPAC:tp
:SCMOD:pdm
:SFLNO:605
:ICOD:S
:QURY:START
select  	  tppdm605.*  ,   
 	   	  tiitm001.buyr,   
 	   	  tiitm001.cwar,   
 	   	  tiitm001.cpgp,   
 	   	  tiitm001.kitm  	   	   	   	   	  |# FP10.n   
from 	  tppdm605, tiitm001
where 	  tppdm605.dfit refers to tiitm001 unref clear   
 |   *  In tcibd001 this condition is present, but in tdipu010, tdpur401, these items are used so the   
 |   *  condition is not added here.   
 | and  	  tppdm605.prit  <>  tppdm.prit.manufactured  	   	  |# FP9  -  HM.n
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:D
:QURY:START
	  if isspace(tiitm002.suno) then  	   	   	   	   	  |# 241014.n   
 	   	  |# only retrieve mapping record when suno is filled  	  |# 241014.n   
 	   	  var.tdipu002.otbp  =  ""    
 	  else  	   	   	   	   	   	   	   	  |# 241014.n   
 	   	  if not get.business.partner(tiitm002.suno, bcstc.orgn.suno, errmess) then   
 	   	   	  var.tdipu002.otbp  =  bcstc008.bpid   
 	   	  endif   
 	  endif  	   	   	   	   	   	   	   	  |# 241014.n   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:td
:SCMOD:pur
:SFLNO:020
:ICOD:D
:QURY:START
	  determine.order.quantities.from.tiitm001(tiitm001.mioq)  	   	  |# 206726.n   
 	  dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:td
:SCMOD:pur
:SFLNO:020
:ICOD:S
:QURY:START
select  	  tdpur020.*  ,   
 	  tiitm001.oqmf,   
 	  tiitm001.mioq,   
 	  tiitm001.maoq,   
 	  tiitm001.fioq,   
 	  tiitm001.ecoq,   
 	  tiitm001.qual,   
 	  tiitm001.oltm,   
 	  tiitm001.omth,  	   	   	   	   	   	  |# 206726.n   
 	  tccom020.qual   
from 	  tdpur020, tiitm001, tccom020
where 	  tdpur020.item refers to tiitm001   
 and  	  tdpur020.suno refers to tccom020   
 and  	  not exists(   
 	   	   	  select tiitm001.item   
 	   	   	  from  	  tiitm001   
 	   	   	  where  	  tiitm001._index1  =  {tdpur020.item}   
 	   	   	  and  	  tiitm001.suno  =  tdpur020.suno)   
 and  	  not exists(   
 	   	   	  select tdpur021.item   
 	   	   	  from  	  tdpur021   
 	   	   	  where  	  tdpur021._index1  =  {tdpur020.item,   
 	   	   	   	   	   	   	  tdpur020.suno})
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:td
:SCMOD:pur
:SFLNO:020
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:td
:SCMOD:pur
:SFLNO:021
:ICOD:D
:QURY:START
	  determine.order.quantities.from.tiitm001(tdpur021.mioq)  	  |# 206726.n   
 	  dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:td
:SCMOD:pur
:SFLNO:021
:ICOD:S
:QURY:START
select  	  tdpur021.*  ,   
 	  tccom020.qual,   
 	  tiitm001.qual,   
 	  tiitm001.oqmf,   
 	  tiitm001.fioq,   
 	  tiitm001.maoq,   
 	  tiitm001.omth,  	   	   	   	   	   	  |# 206726.n   
 	  tiitm001.oltm   
from 	  tdpur021, tccom020, tiitm001
where 	  tdpur021.item refers to tiitm001   
 and  	  tdpur021.suno refers to tccom020   
 and  	  not exists(   
 	   	   	  select  	  tiitm001.item   
 	   	   	  from  	  tiitm001   
 	   	   	  where  	  tiitm001._index1  =  {tdpur021.item}   
 	   	   	  and  	  tiitm001.suno  =  tdpur021.suno)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:td
:SCMOD:pur
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:D
:QURY:START
	  determine.order.quantities.from.tiitm001(  	   	  |# 206726.sn   
 	   	  tiitm001.mioq)  	   	   	   	   	  |# 206726.en   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:S
:QURY:START
select tiitm001.suno,   
 	  tiitm001.item,   
 	  tiitm001.qual,   
 	  tiitm001.oqmf,   
 	  tiitm001.mioq,   
 	  tiitm001.maoq,   
 	  tiitm001.fioq,   
 	  tiitm001.ecoq,   
 	  tiitm001.oltm,   
 	  tiitm001.omth,  	   	   	   	   	  |# 206726.n   
 	  tccom020.qual   
from 	  tiitm001, tccom020
where 	  tiitm001.cont  =  tcyesno.no  	   	   	   	  |# FP9  -  HM.n   
 and  	  tiitm001.suno  <>  ""   
 and  	  tiitm001.suno refers to tccom020 unref clear
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:D
:QURY:START
	  dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:ipu
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:021
:ICOD:S
:QURY:START
select  	  tipcs021.*  , tiitm001.mioq, tiitm001.maoq, tiitm001.fioq, tiitm001.oqmf, tiitm001.qual,   
 	  tccom020.qual   
from 	  tipcs021, tiitm001, tccom020
where 	  tipcs021.suno  <>  ""    
 and  	  tipcs021.dfit refers to tiitm001   
 and  	  tipcs021.suno refers to tccom020
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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()   
 	  	  	  	  	  	  	  	 |#FP22  -  rew.sn   
 	  bcint.dll0000.determine.operational.company.for.warehouse(   
 	  	  	  	  	 tiitm001.cwar,   
 	  	  	  	  	 var.tdisa001.lcmp) 	 |  *  ref   
 	  	  	  	  	  	  	  	 |#FP22  -  rew.en   
 	   	   	   	   	   	   	   	   	  |# 1484915.sn   
 	  if var.tdisa001.alod  =  1 then   
 	   	  |   *  overdelivery allowed   
 	   	  var.tdisa001.mmtl  =  set.max.tolerance(  	     
 	   	   	   	   	   	  "",  	   	   	  |   *  project   
 	   	   	   	   	   	  tiitm001.item,   
 	   	   	   	   	   	  tiitm001.citg,   
 	   	   	   	   	   	  tiitm001.cuni,   
 	   	   	   	   	   	  var.tdisa001.cups)   
 	  else   
 	   	  var.tdisa001.mmtl  =  0.0   
 	  endif   
 	   	   	   	   	   	   	   	   	  |# 1481915.en   
 	  dump 1 |# from tiitm001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:isa
:TFLNO:001
:SCPAC:ti
:SCMOD:itm
:SFLNO:001
:ICOD:S
:QURY:START
select 	 tiitm001.*     
from 	 tiitm001   
 |   *  nvdknaap, 20110307: taken from tcibd001 migration logic  	   	  |   *  FP7  +  .sn   
 |   *  Process items (tiitm001.proi  =  tcyesno.yes) are migrated, but not   
 |   *  the container items (tiitm001.cont  =  tcyesno.yes).
where 	  tiitm001.cont  =  tcyesno.no  	   	   	   	   	  |   *  FP7  +  .en
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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  =  ""    
 	   	   	   	   	   	   	   	   	  |# 1484915.sn   
 	  |   *  overdelivery allowed always yes for this dump   
 	  var.tdisa001.mmtl  =  set.max.tolerance(  	     
 	   	   	   	   	  "",   
 	   	   	   	   	  tipcs002.ccpc,   
 	   	   	   	   	  tiitm001.citg,   
 	   	   	   	   	  tiitm001.cuni,   
 	   	   	   	   	  tipcs002.cuni)   
 	   	   	   	   	   	   	   	   	  |# 1481915.en   
 	  if not isspace(tipcs002.dfit) then 	  	  	 |#FP22  -  rew.sn   
 	  	 var.tdisa001.cwar  =  tiitm001.cwar   
 	  else   
 	  	 var.tdisa001.cwar  =  ""   
 	  endif   
 	  bcint.dll0000.determine.operational.company.for.warehouse(   
 	  	  	  	  	 var.tdisa001.cwar,   
 	  	  	  	  	 var.tdisa001.lcmp) 	 |  *  ref   
 	  	  	  	  	  	  	  	 |#FP22  -  rew.en   
 	  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 |# from tipcs002   
 	   	  endif   
 	  selectempty   
 	   	  |   *  Construct new project code and new item code.   
 	   	  var.project.code  =  get.budget.code(   
 	   	   	   	   	  tipcs002.cbdg,   
 	   	   	   	   	  budg.calc.code)   
 	   	  if not isspace(var.project.code) then   
 	   	   	  var.tdisa001.item  =  segment.item.code(   
 	   	   	   	   	   	  tipcs002.ccpc,   
 	   	   	   	   	   	  var.project.code)   
 	   	   	  dump 4 |# from tipcs002   
 	   	  endif   
 	  endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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.cuni,  	   	   	   	   	   	  |# 1484915.sn   
 	  tiitm001.citg,  	   	   	   	   	   	  |# 1484915.en   
 	  tiitm001.cwar   
from 	  tipcs002, tiitm001
where 	  tipcs002.dfit refers to tiitm001 unref clear
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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)   
 	   	   	   	   	   	   	   	   	  |# 1484915.sn   
 	  |   *  overdelivery allowed always yes for this dump   
 	  var.tdisa001.mmtl  =  set.max.tolerance(  	     
 	   	   	   	   	  tipcs021.cprj,   
 	   	   	   	   	  tipcs021.item,   
 	   	   	   	   	  tiitm001.citg,   
 	   	   	   	   	  tiitm001.cuni,   
 	   	   	   	   	  tipcs021.cuni)   
 	   	   	   	   	   	   	   	   	  |# 1481915.en   
 	  	  	  	  	  	  	  	 |#FP22  -  rew.sn   
 	 bcint.dll0000.determine.operational.company.for.warehouse(   
 	  	  	  	  	 tipcs021.cwar,   
 	  	  	  	  	 var.tdisa001.lcmp) 	 |  *  ref   
 	  	  	  	  	  	  	  	 |#FP22  -  rew.en   
 	  dump 3 |# from tipcs021
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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,   
 	  tipcs021.txta,  	   	   	   	  |# 232167.n   
 	  tiitm001.cpgs,   
 	  tiitm001.cmgp,   
 	  tiitm001.rbgp,   
 	  tiitm001.prir,   
 	  tiitm001.pris,   
 	  tiitm001.ltsp,   
 	  tiitm001.umsp,   
 	  tiitm001.lmsp,   
 	  tiitm001.ddfq,   
 	  tiitm001.cuni,  	   	   	   	   	   	  |# 1484915.sn   
 	  tiitm001.citg,  	   	   	   	   	   	  |# 1484915.en   
 	  tiitm001.cwar   
from 	  tipcs021, tiitm001,   
 	  tipcs020  	   	   	   	   	   	  |# FP7  +  .n
where 	  tipcs021.dfit refers to tiitm001 unref clear   
 | and  	  not exists(  	   	   	   	   	   	  |# FP7  +  .so   
 |  	   	  select  	  tppdm605.item   
 |  	   	  from  	  tppdm605   
 |  	   	  where  	  tppdm605._index1  =  {tipcs021.cprj, tipcs021.item})   
 |  	   	   	   	   	   	   	   	  |# FP7  +  .eo   
 |   *  nvdknaap, 20110307: taken from tcibd001 migration logic  	  |   *  FP7  +  .sn   
 |   *  Do not include customized items from tppdm605,  	   	     
 |   *  duplicate project  &  item codes can exist.   
 and  	  tipcs020.prtp  <>  tcyesno.yes  	   	   	   	  |# FP7  +  .en   
 and  	  tipcs020._index1  =  {tipcs021.cprj}  	   	   	  |# FP7  +  .n
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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()   
 	   	   	   	   	   	   	   	   	  |# 1484915.sn   
 	  if var.tdisa001.alod  =  1 then   
 	   	  |   *  overdelivery allowed   
 	   	  var.tdisa001.mmtl  =  set.max.tolerance(  	     
 	   	   	   	   	   	  tipcs022.cprj,   
 	   	   	   	   	   	  tipcs022.sitm,   
 	   	   	   	   	   	  tiitm001.citg,   
 	   	   	   	   	   	  tiitm001.cuni,   
 	   	   	   	   	   	  var.tdisa001.cups)   
 	  else   
 	   	  var.tdisa001.mmtl  =  0.0   
 	  endif   
 	   	   	   	   	   	   	   	   	  |# 1481915.en   
 	 	 	 	 	 	 	 	 |#FP22 - rew.sn  
 	 bcint.dll0000.determine.operational.company.for.warehouse(  
 	 	 	 	 	 tiitm001.cwar,  
 	 	 	 	 	 var.tdisa001.lcmp) 	 | *  ref  
 	 	 	 	 	 	 	 	 |#FP22 - rew.en  
 	  dump 5 |# from tipcs022
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  if not isspace(tppdm605.dfit) then 	  	  	 |#FP22  -  rew.sn   
 	  	 var.tdisa001.cwar  =  tiitm001.cwar   
 	  else   
 	  	 var.tdisa001.cwar  =  ""   
 	  endif 	  	  	    
 	  bcint.dll0000.determine.operational.company.for.warehouse(   
 	  	  	  	  	 var.tdisa001.cwar,   
 	  	  	  	  	 var.tdisa001.lcmp) 	 |  *  ref   
 	  	  	  	  	  	  	  	 |#FP22  -  rew.en   
 	  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 |# from tppdm605
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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,   
 	  tppdm605.txta,  	   	   	   	  |# 232167.n   
 	  tiitm001.cpgs,   
 	  tiitm001.cmgp,   
 	  tiitm001.rbgp,   
 	  tiitm001.prir,   
 	  tiitm001.umsp,   
 	  tiitm001.lmsp,   
 	  tiitm001.ddfq,   
 	  tiitm001.cwar   
from 	  tppdm605, tiitm001
where 	  tppdm605.prit  <>  tppdm.prit.manufactured  	   	  |# FP9  -  HM.n   
 and  	  tppdm605.dfit refers to tiitm001 unref clear
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:isa
:TFLNO:002
:SCPAC:ti
:SCMOD:itm
:SFLNO:002
:ICOD:D
:QURY:START
	 	 	 	 	 	 	 	 |#FP22 - rew.sn  
 	 bcint.dll0000.determine.operational.company.for.warehouse(  
 	 	 	 	 	 tiitm002.cwar,  
 	 	 	 	 	 var.tdisa002.lcmp) 	 | *  ref  
 	 	 	 	 	 	 	 	 |#FP22 - rew.en  
 	 dump 1
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:030
:ICOD:D
:QURY:START
	  if not conversion.pur030.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.pur030()   
 |  	  read.price.parameters.by.supplier.and.item()  	   	  |# 800  -  142476.o   
 	  if not read.price.parameters.by.supplier.and.item() then |# 800  -  142476.sn   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.pur030()   
 	  handle.prices.pur030()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:030
:ICOD:S
:QURY:START
select  	  tdpur030.*     
from 	  tdpur030
where 	  tdpur030.cntr  =  ""
order by tdpur030._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:030
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:031
:ICOD:D
:QURY:START
	  if not conversion.pur031.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.pur031()   
 |  	  read.discount.parameters.by.supplier.and.price.group() |# 800  -  142476.o   
 	   	   	   	   	   	   	   	  |# 800  -  142476.sn   
 	  if not read.discount.parameters.by.supplier.and.price.group() then   
 	   	  |   *  Parameters not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.pur031()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:031
:ICOD:S
:QURY:START
select  	  tdpur031.*     
from 	  tdpur031
order by tdpur031._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:031
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:032
:ICOD:D
:QURY:START
	  if not conversion.pur032.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.pur032()   
 |  	  read.price.parameters.by.pricelist.and.item.pur037()  	  |# 800  -  142476.o   
 	   	   	   	   	   	   	   	  |# 800  -  142476.sn   
 	  if not read.price.parameters.by.pricelist.and.item.pur037() then   
 	   	  |   *  Parameters not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.pur032()   
 	  handle.prices.pur032()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:032
:ICOD:S
:QURY:START
select  	  tdpur032.*     
from 	  tdpur032
where 	  tdpur032.cntr  =  ""   
 |order by tdpur032._index1 	  	  	  	  	 |#1992229.o   
 	  	  	  	  	  	  	  	 |#1992229.sn
order by tdpur032.cplp, tdpur032.gnpr, tdpur032.item, tdpur032.dile, tdpur032.qanp, tdpur032.stdt   
 	  	  	  	  	  	  	  	 |#1992229.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:032
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:033
:ICOD:D
:QURY:START
	  if not conversion.pur033.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.pur033()   
 	   	   	   	   	   	   	   	  |# 800  -  142476.so   
 |  	  read.discount.parameters.by.price.list.and.price.group.pur035()   
 	   	   	   	   	   	   	   	  |# 800  -  142476.eo   
 	   	   	   	   	   	   	   	  |# 800  -  142476.sn   
 	  if not read.discount.parameters.by.prc.list.and.prc.grp.pur035() then   
 	   	  |   *  Parameters not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.pur033()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:033
:ICOD:S
:QURY:START
select  	  tdpur033.*     
from 	  tdpur033
order by tdpur033._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:033
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:332
:ICOD:D
:QURY:START
	  if not conversion.pur332.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.pur332()   
 |  	  read.purchase.contract.price.parameters()  	   	  |# 800  -  142476.o   
 	  if not read.purchase.contract.price.parameters() then  	  |# 800  -  142476.sn   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.pur332()   
 	  handle.prices.pur332()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:332
:ICOD:S
:QURY:START
select  	  tdpur332.*     
from 	  tdpur332
where 	  tdpur332._index1  =  {:tdpur301.cono, :tdpur301.pono}
order by tdpur332._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:332
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:333
:ICOD:D
:QURY:START
	  if not conversion.pur333.allowed() then   
 	   	  continue   
 	  endif   
 |  	  on case tdpur333.dile   
 |  	  case 1:   
 |  	   	  if isspace(var.discount.schedule1) or   
 |  	   	  g.discount.pur333(1)  =  false then   
 |  	   	   	  continue   
 |  	   	  endif   
 |  	   	  break   
 |  	  case 2:   
 |  	   	  if isspace(var.discount.schedule2) or   
 |  	   	  g.discount.pur333(2)  =  false then   
 |  	   	   	  continue   
 |  	   	  endif   
 |  	   	  break   
 |  	  case 3:   
 |  	   	  if isspace(var.discount.schedule3) or   
 |  	   	  g.discount.pur333(3)  =  false then   
 |  	   	   	  continue   
 |  	   	  endif   
 |  	   	  break   
 |  	  endcase   
 	  initialize.discount.schedule.pur333()   
 |  	  read.purchase.contract.discount.parameters()  	   	  |# 800  -  142476.o   
 	  if not read.purchase.contract.discount.parameters() then |# 800  -  142476.sn   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.pur333()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:333
:ICOD:S
:QURY:START
select  	  tdpur333.*     
from 	  tdpur333
where 	  tdpur333._index1  =  {:tdpur301.cono, :tdpur301.pono}
order by tdpur333._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:pur
:SFLNO:333
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:030
:ICOD:D
:QURY:START
	  if not conversion.sls030.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.sls030()   
 |  	  read.price.parameters.by.customer.and.item()  	   	  |# 800  -  142476.o   
 	  if not read.price.parameters.by.customer.and.item() then |# 800  -  142476.sn   
 	   	  |   *  Price Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.sls030()   
 	  handle.prices.sls030()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:030
:ICOD:S
:QURY:START
select  	  tdsls030.*     
from 	  tdsls030
where 	  tdsls030.cntr  =  ""   
 |order by tdsls030._index1 	  	  	  	  	 |#1992229.o   
 	  	  	  	  	  	  	  	 |#1992229.sn
order by tdsls030.cuno, tdsls030.gnpr, tdsls030.item, tdsls030.dile, tdsls030.qanp, tdsls030.stdt   
 	  	  	  	  	  	  	  	 |#1992229.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:030
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:031
:ICOD:D
:QURY:START
	  if not conversion.sls031.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.sls031()   
 |  	  read.discount.parameters.by.customer()  	   	  |# 800  -  142476.o   
 	  if not read.discount.parameters.by.customer() then  	  |# 800  -  142476.sn   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.sls031()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:031
:ICOD:S
:QURY:START
select  	  tdsls031.*     
from 	  tdsls031
order by tdsls031._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:031
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:032
:ICOD:D
:QURY:START
	  if not conversion.sls032.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.sls032()   
 |  	  read.price.parameters.by.pricelist.and.item.sls037()  	  |# 800  -  142476.o   
 	   	   	   	   	   	   	   	  |# 800  -  142476.sn   
 	  if not read.price.parameters.by.pricelist.and.item.sls037() then   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.sls032()   
 	  handle.prices.sls032()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:032
:ICOD:S
:QURY:START
select  	  tdsls032.*     
from 	  tdsls032
where 	  tdsls032.cntr  =  ""   
 |order by tdsls032._index1 	  	  	  	  	 |#1992229.o   
 	  	  	  	  	  	  	  	 |#1992229.sn
order by tdsls032.cpls, tdsls032.gnpr, tdsls032.item, tdsls032.dile, tdsls032.qanp, tdsls032.stdt   
 	  	  	  	  	  	  	  	 |#1992229.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:032
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:033
:ICOD:D
:QURY:START
	  if not conversion.sls033.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.sls033()   
 	   	   	   	   	   	   	   	  |# 800  -  142476.so   
 |  	  read.discount.parameters.by.price.list.and.price.group.sls035()   
 	   	   	   	   	   	   	   	  |# 800  -  142476.eo   
 	   	   	   	   	   	   	   	  |# 800  -  142476.sn   
 	  if not read.discount.parameters.by.prc.list.and.prc.grp.sls035() then   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.sls033()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:033
:ICOD:S
:QURY:START
select  	  tdsls033.*     
from 	  tdsls033
order by tdsls033._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:033
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:332
:ICOD:D
:QURY:START
	  if not conversion.sls332.allowed() then   
 	   	  continue   
 	  endif   
 	  initialize.discount.schedule.sls332()   
 |  	  read.sales.contract.price.parameters()  	   	   	  |# 800  -  142476.o   
 	  if not read.sales.contract.price.parameters() then  	  |# 800  -  142476.sn   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.sls332()   
 	  handle.prices.sls332()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:332
:ICOD:S
:QURY:START
select  	  tdsls332.*     
from 	  tdsls332
where 	  tdsls332._index1  =  {:tdsls301.cono, :tdsls301.pono}
order by tdsls332._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:332
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:333
:ICOD:D
:QURY:START
	  if not conversion.sls333.allowed() then   
 	   	  continue   
 	  endif   
 |  	  on case tdsls333.dile   
 |  	  case 1:   
 |  	   	  if isspace(var.discount.schedule1) or   
 |  	   	  g.discount.sls333(1)  =  false then   
 |  	   	   	  continue   
 |  	   	  endif   
 |  	   	  break   
 |  	  case 2:   
 |  	   	  if isspace(var.discount.schedule2) or   
 |  	   	  g.discount.sls333(2)  =  false then   
 |  	   	   	  continue   
 |  	   	  endif   
 |  	   	  break   
 |  	  case 3:   
 |  	   	  if isspace(var.discount.schedule3) or   
 |  	   	  g.discount.sls333(3)  =  false then   
 |  	   	   	  continue   
 |  	   	  endif   
 |  	   	  break   
 |  	  endcase   
 	  initialize.discount.schedule.sls333()   
 |  	  read.sales.contract.discount.parameters()  	   	  |# 800  -  142476.o   
 	  if not read.sales.contract.discount.parameters() then  	  |# 800  -  142476.sn   
 	   	  |   *  Parameters are not found.   
 	   	  continue   
 	  endif  	   	   	   	   	   	   	  |# 800  -  142476.en   
 	  handle.discounts.sls333()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:333
:ICOD:S
:QURY:START
select  	  tdsls333.*     
from 	  tdsls333
where 	  tdsls333._index1  =  {:tdsls301.cono, :tdsls301.pono}
order by tdsls333._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pcg
:TFLNO:030
:SCPAC:td
:SCMOD:sls
:SFLNO:333
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:012
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:012
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select 	 bcstc018.pofd,   
 	 bcstc018.pdsc,   
 	 bcstc018._index1   
from bcstc018
order by bcstc018._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:012
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:043
:SCPAC:td
:SCMOD:pur
:SFLNO:043
:ICOD:D
:QURY:START
	  get.group.series.numbers(   
 	   	  bcckon.act.pur,   
 	   	  tdpur043.serp,   
 	   	  error.message)   
 	  get.enterprise.unit(   
 	   	  tdpur043.comp,   
 	   	  get.compnr(),   
 	   	  error.message)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:043
:SCPAC:td
:SCMOD:pur
:SFLNO:043
:ICOD:S
:QURY:START
select tdpur043.*     
from tdpur043
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:043
:SCPAC:td
:SCMOD:pur
:SFLNO:043
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:101
:SCPAC:td
:SCMOD:pur
:SFLNO:002
:ICOD:S
:QURY:START
select 	 tdpur002.*  ,   
 	 tdpur001.cdec, tdpur001.comp, tdpur001.cpay, tdpur001.qspa,   
 	 tdpur001.suno, tdpur001.ccor, tdpur001.ccur, tdpur001.qdat,   
 	 tdpur001.exdt, tdpur001.ratp, tdpur001.ratf, tdpur001.odis,   
 	 tdpur001.rtdt,   
 	 tdpur001.ccon 	  	  	  	  	  	 |#FP23_sy05.n   
 	 |  *  removed markings and added field tdpur001.qspa 	  	  	 |#1908744.n 	    
from 	 tdpur002, tdpur001
where 	 tdpur001._index1  =  {tdpur002.qono}
order by tdpur002._index1
:QURY:END
:TEXT:

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:300
:SCPAC:td
:SCMOD:pur
:SFLNO:300
:ICOD:D
:QURY:START
	 determine.operational.company( 	  	  	  	 |#FP22.sn   
 	  	  	  	 get.purchase.office(),   
 	  	  	  	 convert.warehouse(),   
 	  	  	  	 var.tdpur300.lcmp) 	 |  *  ref   
 	  	  	  	  	  	  	  	 |#FP22.en   
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	 determine.operational.company( 	  	  	  	 |#FP22.sn   
 	  	  	  	 get.purchase.office(),   
 	  	  	  	 tdpur301.cwar,   
 	  	  	  	 var.tdpur301.ncmp) 	 |  *  ref   
 	  	  	  	  	  	  	  	 |#FP22.en   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:303
:SCPAC:td
:SCMOD:pur
:SFLNO:301
:ICOD:S
:QURY:START
select 	 tdpur301.*  ,   
 	 tdpur300.icap,   
 	 tdpur300.sdat   
from 	 tdpur301,   
 	 tdpur300
where 	 tdpur300._index1  =  { 	 tdpur301.cono}
order by tdpur301._index1   
 |  *  Order by is needed to retrieve the same price books  /  discount schedules   
 |  *  in pricing as well as in purchase contract revisions.   
 |  *  Logic must be symchronized with conversion object tdpcg030  !
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:304
:SCPAC:td
:SCMOD:pur
:SFLNO:302
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:304
:SCPAC:td
:SCMOD:pur
:SFLNO:302
:ICOD:S
:QURY:START
select 	 tdpur302.*  ,   
 	 tdpur301.suno  
from 	 tdpur302
where 	 tdpur301._index1  =  { 	 tdpur302.cono, tdpur302.pono}
order by tdpur302._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:304
:SCPAC:td
:SCMOD:pur
:SFLNO:302
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:353
:SCPAC:td
:SCMOD:pur
:SFLNO:306
:ICOD:D
:QURY:START
	 if not conversion.tdpur306.is.allowed() then 	  	 |# SL146557.sn   
 	  	 |  *  conversion is not allowed.   
 	  	 continue   
 	 endif 	  	  	  	  	  	  	 |# SL146557.en   
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:353
:SCPAC:td
:SCMOD:pur
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:040
:ICOD:D
:QURY:START
	  g.order.activity  =  true   
 	  tdpur045.orno  =  tdpur040.orno   
 	  dump.purchase.order.activities()  	   	   	  |# FP10.n   
 |  	  fill.purchase.order.activities()  	   	   	  |# FP10.o
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:040
:ICOD:S
:QURY:START
select  	  tdpur040.orno, tdpur040.cotp  	   	   	   	  |# 232965.sn   
from 	  tdpur040
where not exists(  	  select  	  tdpur041.orno   
 	   	   	  from  	  tdpur041   
 	   	   	  where  	  tdpur041.orno  =  tdpur040.orno)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:040
:ICOD:X
:QURY:START
	   	   	   	   	   	  |# 232965.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	   	   	   	   	   	   	  |# 1470346.sn   
 	  if not bcint.dll0000.purchase.order.line.must.be.created(   
 	   	   	   	   	  tdpur045.srnb,   
 	   	   	   	   	  tdpur045.date,   
 	   	   	   	   	  tdpur041.bqua) then   
 	   	  |   *  In some situations, no order line sequence must   
 	   	  |   *  be created; e.g.:   
 	   	  |   *  1. if the backorder quantity has been set to   
 	   	  |   *   zero in tdpur041.bqua.   
 	   	  continue   
 	  endif  	   	   	   	   	   	  |# 1470346.en   
 	  handle.dump.order.header.data()  	   	   	  |# 1470346.sn   
 	  handle.dump.order.line.and.related.data()  	     
 	  handle.dump.total.line()  	   	   	   	     
 	  handle.dump.extra.backorder.line()   
 	  handle.dump.receipt.data()  	   	   	   	  |# 1470346.en   
 	  |   *  Set variables for next iteration   
 |  	  read.purchase.order.and.related.data()  	   	  |# FP10.so   
 |  	  g.order.activity  =  true  	   	   	   	  |# FP3.sn   
 |  	  fill.purchase.order.activities()   
 |  	  g.order.activity  =  false  	   	   	   	  |# FP3.en   
 |    
 |    
 |  	  g.no.of.receipt.lines  =  get.number.of.receipt.lines()   
 |  	  var.receipt.number  =  get.receipt.number()  	   	  |# 205206.n   
 |  	   	   	   	   	   	   	   	  |# FP10.eo   
 	  |   *  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  	   	   	  |# FP10.so   
 |  	  tdpur045.srnb  <>  0 then   
 |  	   	  dump 1  	  |   *  tdpur401   
 |  	   	  if linked.order.line.data.present() then   
 |  	   	   	  dump 2  	  |   *  tdpur402   
 |  	   	  endif   
 |  	   	   	   	   	   	   	   	  |# SP2.sn   
 |  	   	  if get.order.line.type()  =  target(tdgen.oltp.orderline) then   
 |  	   	   	  |   *  tdpur411 is only created for type   
 |  	   	   	  |   *  'order line' and for type 'total'. For   
 |  	   	   	  |   *  type 'total', see section 'Insert Total   
 |  	   	   	  |   *  Line'.   
 |  	   	   	  dump 4  	  |   *  tdpur411   
 |  	   	  endif  	   	   	   	   	   	  |# SP2.en   
 |  	   	  fill.purchase.order.line.activities()  	   	  |# FP3.n   
 |  	  endif   
 |  	  |   *  Insert Total Line   
 |  	  if tdpur045.srnb  =  0 and   
 |  	  g.no.of.receipt.lines  >  1 then   
 |  	   	  |   *  When there is more than one receipt, then there   
 |  	   	  |   *  is a backorder line, so a total line must be   
 |  	   	  |   *  created.   
 |  	   	  g.total.line  =  true   
 |  	   	  get.total.line.values()   
 |  	   	  dump 1  	  |   *  tdpur401   
 |  	   	   	   	   	   	   	   	  |# SP2.sn   
 |  	   	  |   *  tdpur411 will be connected to the total.   
 |  	   	  dump 4  	  |   *  tdpur411   
 |  	   	   	   	   	   	   	   	  |# SP2.en   
 |  	   	  g.total.line  =  false   
 |  	  endif   
 |  	     
 |  	  |   *  Insert extra Backorder Line for Direct Delivery   
 |  	  if tdpur045.srnb  =  g.last.sequence.number and   
 |  	  g.extra.bo.line.must.be.inserted then   
 |  	   	  g.extra.dir.del.bo.line  =  true   
 |  	   	  dump 1  	  |   *  tdpur401   
 |  	   	  dump 2  	  |   *  tdpur402   
 |  	   	  fill.purchase.order.line.activities()  	   	  |# FP3.n   
 |  	   	  g.extra.dir.del.bo.line  =  false   
 |  	  endif   
 |  	  |   *  Insert Actual Receipt   
 |  	  if tdpur045.date  <>  0 then   
 |  	   	  |   *  When the actual receipt date is filled, a receipt   
 |  	   	  |   *  is done and a record in tdpur406 must be entered.   
 |  	   	  dump 3  	  |   *  tdpur406   
 |  	   	  dump 5  	  |   *  tdpur456   
 |  	   	  dump 7  	  |   *  tdpur430   
 |  	  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  	   	   	  |# FP10.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:pur
:TFLNO:401
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:F
:QURY:START
	   	   	   	   	   	   	  |# 1061231.n   
 	  free.mem(s.array.receipt.line)  	   	   	   	  |# 1061231.n   
 	  free.mem(s.array.cost.line)  	   	   	   	  |# 1382005.n
:QURY:END
:TEXT:

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:012
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:012
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select 	 bcstc018.sofd,   
 	 bcstc018.sdsc,   
 	 bcstc018._index1   
from 	 bcstc018
order by bcstc018._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:012
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:027
:SCPAC:td
:SCMOD:sls
:SFLNO:027
:ICOD:D
:QURY:START
|# 800  -  142478.sn   
 	 if isspace(tdsls027.ccos) then   
 	  	 |  *  Field is mandatory on the target side cannot migrate these   
 	  	 |  *  records to the target.   
 	  	 |  *  The functionality to exclude BP for a default cost set is   
 	  	 |  *  not suported on the target.   
 	  	 continue   
 	 endif   
 |# 800  -  142478.en   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:027
:SCPAC:td
:SCMOD:sls
:SFLNO:027
:ICOD:S
:QURY:START
select tdsls027.*   
from tdsls027
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:027
:SCPAC:td
:SCMOD:sls
:SFLNO:027
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:039
:SCPAC:td
:SCMOD:sls
:SFLNO:039
:ICOD:D
:QURY:START
	  |   *  Retrieve the converted BIV Serie via bcstc024   
 	  if get.group.series.numbers(   
 	   	  bcckon.act.sls,   
 	   	  tdsls039.sers,   
 	   	  o.errmess)  <>  0 then   
 	   	  |   *  Error detected   
 	  endif   
 	    
 	  |   *  make bcstc018 current to get sales office   
 	  if get.enterprise.unit(   
 	   	  tdsls039.comp, |   *  Financial company   
 	   	  get.compnr(),  	  |   *  Logistic company   
 	   	  o.errmess)  <>  0 then   
 	   	  |   *  Error detected   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:039
:SCPAC:td
:SCMOD:sls
:SFLNO:039
:ICOD:S
:QURY:START
select tdsls039.*    
from tdsls039
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:039
:SCPAC:td
:SCMOD:sls
:SFLNO:039
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:090
:SCPAC:bc
:SCMOD:std
:SFLNO:003
:ICOD:D
:QURY:START
 
 	  dump 1  
 
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:090
:SCPAC:bc
:SCMOD:std
:SFLNO:003
:ICOD:S
:QURY:START
 select  	  bcstd003.*
from  	  bcstd003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:090
:SCPAC:bc
:SCMOD:std
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:101
:SCPAC:td
:SCMOD:sls
:SFLNO:002
:ICOD:D
:QURY:START
	  e  =  get.tax.by.country.code.and.financial.company(   
 	   	  tdsls002.ccty,   
 	   	  tdsls002.cvat,   
 	   	  tdsls001.comp,   
 	   	  var.tdsls101.ccty,   
 	   	  var.tdsls101.cvat,   
 	   	  g.error.mess)   
 	   	   	   	   	   	   	   	   	   	  |# 1367218.sn   
 	  retrieve.item.data(   
 	   	   	  tdsls002.item,  	  |# Item   
 	   	   	  tdsls002.cprj,  	  |# Project   
 	   	   	  tdsls002.cbdg,  	  |# Budget   
 	   	   	  tdsls002.opol,  	  |# Item Category   
 	   	   	  var.tdsls101.cwar,  	  |# output: Item Warehouse   
 	   	   	  var.tdsls101.nids)  	  |# output: Item Description   
 	   	   	   	   	   	   	   	   	   	  |# 1367218.en  	   	     
 	  dump 1 |# tdsls101
:QURY:END
:TEXT:

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

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

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

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

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

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

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:040
:ICOD:D
:QURY:START
	  g.order.activity  =  true   
 	  g.delivery.has.been.done  =  false 	  	  	 |#1710355.n   
 	  tdsls045.orno  =  tdsls040.orno   
 	  fill.sales.order.activities()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:040
:ICOD:S
:QURY:START
select  	  tdsls040.orno, tdsls040.cotp  	   	   	  |# 232965.sn   
from 	  tdsls040
where not exists(  	  select tdsls041.orno   
 	   	   	  from  	  tdsls041   
 	   	   	  where  	  tdsls041.orno  =  tdsls040.orno)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:040
:ICOD:X
:QURY:START
	   	   	   	   	   	  |# 232965.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:045
:ICOD:D
:QURY:START
	  |  *  Create header related data 	  	  	  	 |#1710355.sn   
 	  read.sales.order.and.order.type.data()   
 	  read.item.data()  	   	   	   	     
 	  g.total.line  =  false   
 	  g.delivery.has.been.done  =  false  	   	   	    
 	  var.shipment  =  ""  	    
 	  var.shipment.line  =  0   
 	  g.order.activity  =  true  	   	   	   	    
 	  fill.sales.order.activities()   
 	  |   *  This function performs a dump 8 for the order header.   
 	  g.order.activity  =  false 	  	  	  	 |#1710355.en   
 	  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() 	  	 |#1710355.so   
 | 	  read.item.data()  	   	   	   	     
 | 	  g.total.line  =  false   
 | 	  g.delivery.has.been.done  =  false  	   	   	  |# 1441944.n   
 | 	  var.shipment  =  ""  	  |# SL204550.sn    
 | 	  var.shipment.line  =   	 0 	  	  	  	 |#1710355.eo   
 	  |   *  Insert Order Line   
 	  |   *************************************************************     
 	  |   *  The following line types will be converted in tdsls401 in   
 	  |   *  the next cases:   
 	  |   *  1. Only one record in tdsls045 with srnb  =  0:   
 	  |   *    	   	   	  1 order line (sqnb 0)   
 	  |   *  2. Record in tdsls045 with srnb  >  0:   
 	  |   *    	   	   	  1 total line (sqnb 0)   
 	  |   *    	   	   	  1 detail line (sqnb 1)   
 	  |   *    	   	   	  1 backorder line (sqnb 2) etc   
 	  |   *  Dump1 For tdsls401:   
 	  |   *    	   	    -  Total lines   
 	  |   *    	   	    -  Detail lines (sqnb  =  0)   
 	  |   *    	   	    -  Backorder lines (sqnb  >  0)   
 	  |   *  Dump2 For tdsls402:   
 	  |   *    	   	    -  Linked order line data   
 	  |   *  Dump3 For tdsls406:   
 	  |   *    	   	    -  Actual order lines (tdsls045.date  <>  0)   
 	  |   *  Dump4 For tcibd410:   
 	  |   *    	   	    -  Lot and serial set for the actual delivery line   
 	  |   *  Dump5 For tcibd411:   
 	  |   *    	   	    -  Lot and serial set detail for the actual delivery line   
 	  |   *  Dump6 For tdsls409:   
 	  |   *    	   	    -  actual cogs record for the actual delivery line (1:1)   
 	  |   *  Dump7 For tdsls411:   
 	  |   *    	   	    -  Sales order line item data   
 	  |   *  Dump8 For tdsls413:   
 	  |   *    	   	    -  Sales order line activities   
 	  |   *  Dump9 For tdsls415:   
 	  |   *    	   	    -  Sales order Estimated COGS   
 	  |   *************************************************************     
 | 	  	  	  	  	  	  	  	 |#1710355.so   
 | 	  g.order.activity  =  true  	   	   	   	  |# FP3.sn   
 | 	  fill.sales.order.activities()   
 | 	  |   *  This function performs a dump 8 for the order header.   
 | 	  g.order.activity  =  false  	   	   	   	  |# FP3.en   
 | 	  	  	  	  	  	  	  	 |#1710355.eo   
 	     
 |  	  if g.ilc.implemented then  	   	   	   	  |# 247201.o   
 	  if g.ilc.implemented and  	   	   	   	  |# 247201.sn   
 	  tdsls041.isss  <>  tcisss.issue.comp then  	   	  |# 247201.en   
 	   	  migrate.outbound.data.to.sales.order.deliveries()   
 	   	  |   *  This function will perform a dump1 and dump2   
 	   	  |   *  for each tdilc401 record.   
 	   	  fill.sales.order.line.activities()  	   	  |# FP# .sn   
 	   	  |   *  This function performs a dump 8 for the order line   
 	   	  dump 9 |   *  tdsls415 Sales Order Estimated COGS   
 	   	   	   	   	   	   	   	  |# FP3.en   
 	  else   
 	   	  determine.var.shpm.and.shln()   
 	  	  determine.var.rcid.and.rcln() 	  	  	 |#1866729.n   
 	   	  dump 1 |   *  tdsls401 (convert detail or backorder record)   
 	   	  if convert.linked.order.line.data() then   
 	   	   	  dump 2 |   *  tdsls402 (linked order line data)   
 	   	  endif   
 	   	  determine.delivery.based.vars()  	   	  |# FP8.n   
 	   	  fill.sales.order.line.activities()  	   	  |# FP3.sn   
 	   	  |   *  This function performs a dump 8 for the order line   
 	   	  dump 9 |   *  tdsls415 Sales Order Estimated COGS   
 	   	   	   	   	   	   	   	  |# FP3.en   
 	   	  handle.dump.sales.delivery.line()  	   	  |# FP8.n   
 	  endif   
 	  |   *  tdsls401 Insert Total Line record:   
 	  |   *  When there is more than one delivery line, then there is a   
 	  |   *  backorder line, so a total line must be created. But also when no   
 	  |   *  backorder line is present but the backorder quantity  <>  0 then a   
 	  |   *  backorder is expected and a total line will be created.   
 	  |   *  For a Total line no linked order line data will be inserted.   
 	  if tdsls045.srnb  =  0 and total.line.required() then   
 	   	  g.total.line  =  true   
 	   	  get.total.line.values()   
 	   	  determine.var.shpm.and.shln()   
 	  	  determine.var.rcid.and.rcln() 	  	  	 |#1866729.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 and   
 |  	  not g.ilc.implemented then  	   	   	   	  |# 247201.o   
 	  (not g.ilc.implemented or  	   	   	   	  |# 247201.sn   
 	  tdsls041.isss  =  tcisss.issue.comp) then  	   	  |# 247201.en   
 	  |   *  For ilc implemented the actual deliveries for the delivered   
 	  |   *  outbound advices are handled in function   
 	  |   *  migrate.outbound.data.to.sales.order.deliveries   
 	   	  if isspace(var.shipment) then   
 	   	   	  determine.var.shpm.and.shln()   
 	   	  endif   
 	  	  determine.var.rcid.and.rcln() 	  	  	 |#1866729.n   
 	   	  dump.actual.delivery()   
 	   	  dump.actual.delivery.history()  	   	  |# FP7  -  nk.n   
 	   	  fill.sales.order.actual.delivery.line.activities() |# FP8.n   
 	  endif   
 	   	   	   	   	   	   	   	     
 	  |   *  tdsls411 will always be created for sequence 0 (total or detail).   
 	  if tdsls045.srnb  =  0 then  	   	   	   	  |# 223664.n   
 	   	  dump 7  	  |   *  tdsls411  -  Sales order line item data   
 	  endif  	   	   	   	   	   	   	  |# 223664.n   
 	   	   	   	   	   	   	   	
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:D
:QURY:START
	  |   *  Installments have position 0 and will therefore also move to tdsls456   
 	  create.turnover.history.records()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:S
:QURY:START
select  	  tdsls051.*    	   	   	   	   	   	  |# 1455994.sn   
from 	  tdsls051
where 	  tdsls051.ckor  =  3  	  |   *  3  =  TURNOVER   
 and  	  tdsls051.pono  <>  0   
 and not exists (select  	  tdsls041.orno   
 	   	  from  	  tdsls041   
 	   	  where  	  tdsls041._index1  =  {  	  tdsls051.orno,   
 	   	   	   	   	   	  tdsls051.pono})
order by tdsls051._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:401
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:X
:QURY:START
	     
 	   	   	   	   	   	   	   	  |# 1455994.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:404
:SCPAC:td
:SCMOD:rpl
:SFLNO:100
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:404
:SCPAC:td
:SCMOD:rpl
:SFLNO:100
:ICOD:S
:QURY:START
select 	 tdrpl100.sorn, tdrpl100.spon, tdrpl100.rwar,   
 	 tdrpl100.oqua, tdrpl100.rddt, tdrpl100.pddt,   
 	 tdrpl100.orno, tdrpl100.pono, tdrpl100.srnb  
from 	 tdrpl100
where 	 tdrpl100.sorn  <>  0
order by tdrpl100._index9
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:404
:SCPAC:td
:SCMOD:rpl
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:D
:QURY:START
	  if tdsls051.ckor  =  3 and  	   	   	  |# 1455994.sn   
 	  tdsls051.pono  <>  0 then   
 	   	  skip.turnover.deliveries  =  skip.turnover.deliveries  +  1   
 	   	  continue   
 	  endif  	   	   	   	   	   	  |# 1455994.en  	   	   	     
 	  read.sales.order.header.history()   
 	  read.item.data()   
 	  convert.tax()  	   	   	   	     
 	  dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:td
:TCMOD:sls
:TFLNO:451
:SCPAC:td
:SCMOD:sls
:SFLNO:051
:ICOD:X
:QURY:START
if skip.turnover.deliveries  >  0 then  	   	   	  |# 1455994.sn   
 	  log.error.data(   
 	   	  str$(skip.turnover.deliveries)  &  " records are skipped"  &     
 	   	  " because turnover for deliveries is logged in tdsls456 -"  &     
 	   	  " Sales Order Actual Delivery Lines History.")   
 endif  	   	   	   	   	   	   	  |# 1455994.en
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:100
:SCPAC:tf
:SCMOD:acp
:SFLNO:100
:ICOD:D
:QURY:START
	  for element  =  1 to 3   
 	   	  if calculate.amount.in.home.currency(   
 	   	   	   	  tfacp100.amnt,   
 	   	   	   	  tfacp100.ccur,   
 	   	   	   	  tfacp100.rate,   
 	   	   	   	  tfacp100.ratf,   
 	   	   	   	  element,   
 	   	   	   	  var.tfacp100.amth(element),   
 	   	   	   	  error.message)  <>  0 then   
 	   	   	  var.tfacp100.amth(element)  =  0.0   
 	   	  endif   
 	   	  var.tfacp100.rate(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp100.rate,   
 	   	   	   	  element,   
 	   	   	   	  0.000001)  	     
 	   	  var.tfacp100.ratf(element)  =  fill.mc.field.long(   
 	   	   	   	  tfacp100.ratf,   
 	   	   	   	  element,   
 	   	   	   	  1)  	     
 	  endfor   
 	  var.tfacp100.rade  =  get.tfacp100.rade(tfacp100.spot)   
 	     
 	  if tfacp100.stin  =  empty then   
 	   	  var.tfacp100.stin  =  tfacp.stin.open  	  |   *  Open   
 	  else   
 	   	  var.tfacp100.stin  =  tfacp100.stin   
 	  endif   
 	     
 	  fill.dimensions(   
 	   	  tfacp100.suno,   
 	   	  var.tfacp100.dim1,   
 	   	  var.tfacp100.dim2,   
 	   	  var.tfacp100.dim3,   
 	   	  var.tfacp100.dim4,   
 	   	  var.tfacp100.dim5)   
 	     
 	  var.tfacp100.isup  =  tfacp100.isup  	  |# 1360713.sn   
 	  var.tfacp100.isup  =  toupper$(var.tfacp100.isup)  	     
 	  var.tfacp100.isup  =  shiftl$(var.tfacp100.isup) |# 1360713.en   
 	     
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:100
:SCPAC:tf
:SCMOD:acp
:SFLNO:100
:ICOD:S
:QURY:START
select tfacp100.*     
from tfacp100
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:100
:SCPAC:tf
:SCMOD:acp
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:101
:SCPAC:tf
:SCMOD:acp
:SFLNO:101
:ICOD:D
:QURY:START
	  for element  =  1 to 3   
 	   	  var.tfacp101.amth(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp101.amth,   
 	   	   	   	  element,   
 	   	   	   	  0.0)   
 	  endfor  	   	     
 	  if not isspace(tfacp101.orno) then   
 	   	  get.logistic.company(   
 	   	   	  tfacp101.orno,   
 	   	   	  finance.company,   
 	   	   	  var.tfacp101.loco)   
 	  else   
 	   	  var.tfacp101.loco  =  0   
 	  endif  	     
 	  if tfacp101.orno  <>  0 then   
 	   	  var.tfacp101.otyp  =  target(tfacp.otyp.purchase)   
 	  else   
 |  	   	  var.tfacp101.otyp  =  0  	   	   	   	  |# migration fp5.o   
 	   	  var.tfacp101.otyp  =  target(tfacp.otyp.not.applicable)  	  |# migration fp5.o   
 	  endif   
 	  if tfgld008.ifas  <>  empty then   
 	   	  fill.asset.reference(   
 	   	  tfgld008.ifas,   
 	   	  tfacp101.comp,   
 	   	  tfacp101.ttyp,   
 	   	  tfacp101.ninv,   
 	   	  tfacp101.sern,   
 	   	  bcstf000.asex,  	  |   *  Fixed Asset Extension   
 	   	  var.tfacp101.refr,   
 	   	  var.tfacp101.ref2)   
 	  else   
 	   	  var.tfacp101.refr  =  tfacp101.refr   
 	   	  var.tfacp101.ref2  =  ""    
 	  endif  	     
 	     
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:101
:SCPAC:tf
:SCMOD:acp
:SFLNO:101
:ICOD:S
:QURY:START
select tfacp101.*  , tfgld008.ifas   
from tfacp101, tfgld008
where tfacp101.leac refers to tfgld008
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:101
:SCPAC:tf
:SCMOD:acp
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	   	   	   	   	   	   	   	   	  |# 1431629.sn   
 	   	   	  |   *  For factoring companies the code has a length of 3 and needs to   
 	   	   	  |   *  be converted into a code for domain tccuno   
 	   	   	  conv.factor.company  =  bcint.dll0000.convert.factoring.code.for.bcstc008(   
 	   	   	   	   	   	   	   	   	  hold.factor.company)   
 	   	   	   	   	   	   	   	   	   	  |# 1431629.en   
 	   	   	  var.tfacp200.ptbp  =  get.business.partner.code(   
 |  	   	   	   	   	   	  shiftr$(hold.factor.company), |# 1431629.o   
 	   	   	   	   	   	  conv.factor.company,  	   	  |# 1431629.n   
 	   	   	   	   	   	  bcstc.orgn.fcomp,   
 	   	   	   	   	   	  error.message)   
 	   	   	  |   *  Pay  -  to business partner is the converted factor   
 	   	   	  |   *  company   
 	   	  else   
 	   	   	  var.tfacp200.ptbp  =  business.partner   
 	   	   	  factor.bank  =  ""    
 	   	   	  hold.factor.company  =  ""    
 	   	  endif  	     
 	  endif  	     
 	     
 	  if (tfacp200.spot  =  tcyesno.yes) then   
 	   	  var.tfacp200.rade  =  target(tcfcrt.fixed) |   *  Fixed   
 	  else   
 |  	   	  var.tfacp200.rade  =  target(tcfcrt.manual)  	  |# 200704.so   
 |  	   	   	   	   	   	  |   *  Manually entered   
 |  	   	   	   	   	   	   	   	  |# 200704.eo   
 	   	  var.tfacp200.rade  =  target(tcfcrt.docd)  	  |# 200704.sn   
 	   	   	   	   	   	  |   *  Document Date |# 200704.en   
 	  endif   
 	     
 	  if not isspace(hold.factor.company) then   
 	   	  var.tfacp200.bank  =  factor.bank   
 	  else   
 	   	  var.tfacp200.bank  =  tfacp200.bank   
 	  endif  	     
 	     
 	  |   *  Baan IV  	   	  Baan 6   
 	  |   *  no  	   	   	  1  	  expence  	   	  1   
 	  |   *  pur  	   	  2  	  purchase  	   	  2   
 	  |   *  tran  	   	  3  	  expence  	   	  1   
 	  if tfacp200.appr  =  tfacp.matc.tran then   
 	   	  var.tfacp200.appr  =  target(tfacp.inv.expence)   
 	   	  var.tfacp200.link  =  0.0   
 	  else   
 	   	  var.tfacp200.appr  =  etol(tfacp200.appr)   
 	   	  var.tfacp200.link  =  tfacp200.link   
 	  endif   
 	  |   *  Old function for reading mapping table activated again  	  |# 210859.n   
 	   	   	   	   	   	   	   	  |# 210859.so   
 |  	  ret.long  =  get.tax.by.country.code(   
 |  	   	   	  tfacp200.vatc,   
 |  	   	   	  tfacp200.cvat,   
 |  	   	   	  var.tfacp200.vatc,   
 |  	   	   	  var.tfacp200.cvat,   
 |  	   	   	  error.message)   
 	   	   	   	   	   	   	   	  |# 210859.eo   
 	  if tfacp200.lvat  =  tfacp.vatc.header then  	   	  |# 1359481.n   
 	   	  ret.long  =  get.tax.by.country.code.and.financial.company(   
 	   	   	   	  tfacp200.vatc,   
 	   	   	   	  tfacp200.cvat,   
 	   	   	   	  current.company,   
 	   	   	   	  var.tfacp200.vatc,   
 	   	   	   	  var.tfacp200.cvat,   
 	   	   	   	  error.message)   
 	  else  	   	   	   	   	   	   	  |# 1359481.sn   
 	   	  var.tfacp200.vatc  =  ""  	     
 	   	  var.tfacp200.cvat  =  ""  	     
 	  endif  	   	   	   	   	   	  |# 1359481.en   
 |  	  if not isspace(tfacp200.vatc) then  	  |# SP2.sn  	  |# 210859.so   
 |  	   	  var.tfacp200.vatc  =  get.country.of.financial.company(   
 |  	   	   	   	   	  current.company)   
 |  	  endif  	   	   	   	   	  |# SP2.en  	  |# 210859.eo   
 	     
 	  if tfacp200.step  <>  empty then   
 	   	  convert.payment.procedure.step(   
 	   	   	  tfacp200.step,   
 	   	   	  var.tfacp200.step)   
 	  else   
 |  	   	  var.tfacp200.step  =  0  	   	   	  |# 225015.o   
 	   	  var.tfacp200.step  =  target(tfcmg.step.empty) |# 225015.n   
 	  endif   
 	  if tfacp200.vatp  =  0 or tfacp200.vaty  =  0 then   
 	  |   *  Vat period is mandatory in BaanIV and SSA ERP LN (Baan 6).   
 	  |   *  It turns out that in some rare cases tfacp200.vatp is empty (0).   
 	  |   *  So, to be sure vatp and vaty are always filled.   
 	   	  itfgld0012.get.year.prno.from.date(   
 	   	   	  current.company,   
 	   	   	  tfgld.ptyp.vat,   
 	   	   	  tfacp200.docd)   
 	   	  var.tfacp200.vaty  =  igld0012.year   
 	   	  var.tfacp200.vatp  =  igld0012.prno   
 	  else   
 	   	  var.tfacp200.vaty  =  tfacp200.vaty   
 	   	  var.tfacp200.vatp  =  tfacp200.vatp   
 	  endif   
 	  if tfacp200.blac  =  empty then   
 	   	  var.tfacp200.blac  =  target(tfcmg.blac.na) |   *  Not applicable   
 	  else   
 	   	  var.tfacp200.blac  =  etol(tfacp200.blac)   
 	  endif  	     
 	   	   	   	   	   	   	   	  |# FP3.sn   
 	  if isspace(tfacp200.tdoc) and   
 	  ((tfacp200.tpay  =  tfacp.tpay.invoice) or   
 	  (tfacp200.tpay  =  tfacp.tpay.credit) or   
 	  (tfacp200.tpay  =  tfacp.tpay.advance) or   
 	  (tfacp200.tpay  =  tfacp.tpay.unallocated)) then  	     
 	   	  get.control.account(   
 	   	  current.company,   
 	   	  tfacp200.year,   
 	   	  tfacp200.btno,   
 	   	  tfacp200.ttyp,   
 	   	  tfacp200.ninv,   
 	   	  tfacp200.line,   
 	   	  tfacp200.tpay,   
 	   	  var.tfacp200.leac,   
 	   	  var.dimension1,  	   	   	   	  |# 1056135.sn   
 	   	  var.dimension2,  	   	   	   	     
 	   	  var.dimension3,  	   	   	   	     
 	   	  var.dimension4,  	   	   	   	     
 	   	  var.dimension5)  	   	   	   	  |# 1056135.en   
 	  else   
 	   	  var.tfacp200.leac  =  ""    
 	   	  var.dimension1  =  ""  	   	   	   	  |# 1056135.sn    
 	   	  var.dimension2  =  ""  	   	   	   	     
 	   	  var.dimension3  =  ""  	   	   	   	     
 	   	  var.dimension4  =  ""  	   	   	   	     
 	   	  var.dimension5  =  ""  	   	   	   	  |# 1056135.en    
 	  endif  	   	   	   	   	   	   	  |# FP3.en   
 	     
 	  for element  =  1 to 3   
 	   	  var.tfacp200.rate(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.rate, element, 0.000001)  	     
 	   	  var.tfacp200.ratf(element)  =  fill.mc.field.long(   
 	   	   	   	  tfacp200.ratf, element, 1)  	     
 	   	  var.tfacp200.amth(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.amth, element, 0.0)   
 	   	  var.tfacp200.vath(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.vath, element, 0.0)   
 	   	  var.tfacp200.svah(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.svah, element, 0.0)   
 	   	  var.tfacp200.laph(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.laph, element, 0.0)   
 	   	  var.tfacp200.dc1h(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.dc1h, element, 0.0)   
 	   	  var.tfacp200.dc2h(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.dc2h, element, 0.0)   
 	   	  var.tfacp200.dc3h(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.dc3h, element, 0.0)   
 	   	  var.tfacp200.padh(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.padh, element, 0.0)   
 	   	  var.tfacp200.cdam(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.cdam, element, 0.0)   
 	   	  var.tfacp200.tore(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.tore, element, 0.0)   
 	   	  var.tfacp200.baca(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.baca, element, 0.0)   
 	   	  var.tfacp200.balh(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.balh, element, 0.0)   
 	   	  var.tfacp200.bahc(element)  =  fill.mc.field.double(   
 	   	   	   	  tfacp200.bahc, element, 0.0)   
 	  endfor  	   	     
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	  get.payment.info(   
 	   	  var.tfacp200.pcom,  	   	     
 	   	  var.tfacp200.payt,   
 	   	  var.tfacp200.payd,   
 	   	  var.tfacp200.payl)   
 	   	   	   	   	   	   	   	  |# FP7.en   
 	     
 	  var.tfacp200.isup  =  tfacp200.isup  	   	   	  |# 1360713.sn   
 	  var.tfacp200.isup  =  toupper$(var.tfacp200.isup)   
 	  var.tfacp200.isup  =  shiftl$(var.tfacp200.isup)  	   	  |# 1360713.en   
 	  	  	  	  	  	  	  	 |#1919672.sn   
 	 invoice.is.finalized(   
 	  	 tfacp200.ttyp,   
 	   	 tfacp200.ninv,   
 	   	 var.tfacp200.post,   
 	   	 var.tfacp200.pdat)   
 	  	  	  	  	  	  	  	 |#1919672.en   
 	  dump 1   
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	  if isspace(tfacp200.tdoc) then   
 	   	  var.tfacp500.toba  =  tfacp200.balc  -  tfacp200.bala   
 	   	  if double.cmp(var.tfacp500.toba, 0.0, 0.0001)  =  0 then   
 	   	   	  var.tfacp500.flpd  =  tcyesno.yes   
 	   	  else   
 	   	   	  var.tfacp500.flpd  =  tcyesno.no   
 	   	  endif   
 	  	 get.supplier.fin.business.partner.group( 	  	  	 |#Migr. 10.6.sn   
 	  	  	  	 current.company,   
 	  	  	  	 tfacp200.suno,   
 	  	  	  	 var.tfacp500.fisu) 	 |  *  ref 	 |#Migr. 10.6.en   
 	   	  dump 2  	     
 	  endif   
 	   	   	   	   	   	   	   	  |# FP7.en
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:D
:QURY:START
	   	  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 |# 242900.o   
 	   	   	  if (prev.item  <>  tdpur041.item) or  	  |# 242900.sn   
 	   	   	  (prev.item.category  <>  tdpur041.opol ) or   
 	   	   	  (prev.project  <>  tdpur041.cprj) then |# 242900.en   
 	   	   	   	  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   
 	   	   	   	  prev.item.category  =  tdpur041.opol |# 242900.sn   
 	   	   	   	  prev.project  =  tdpur041.cprj  	  |# 242900.en   
 	   	   	  endif   
 	   	   	  get.number.of.receipt.lines(   
 	   	   	   	  tdpur041.orno,   
 	   	   	   	  tdpur041.pono,   
 	   	   	   	  logistic.company,   
 	   	   	   	  no.of.receipt.lines)   
 	   	   	  var.tfacp240.cadr  =  get.delivery.address ()   
 	   	   	  |   *  Function to retrieve GL  -  code   
 	   	   	  |   *  tdpur041.pacn, dim1  -  dim5   
 	   	   	  var.tfacp240.glco  =  transform.leac.and.dim.in.gl.code(   
 	   	   	   	   	   	  tdpur041.pacn,   
 	   	   	   	   	   	  tdpur041.dim1,   
 	   	   	   	   	   	  tdpur041.dim2,   
 	   	   	   	   	   	  tdpur041.dim3,   
 	   	   	   	   	   	  tdpur041.dim4,   
 	   	   	   	   	   	  tdpur041.dim5)   
 	   	   	  var.tfacp240.vatc  =  ""  	   	  |# 210859.n    
 	   	   	  var.tfacp240.cvat  =  ""  	   	  |# 210859.n    
 	   	   	  if not isspace(tdpur041.ccty) then  	  |# SP2.sn   
 	   	   	   	   	   	   	   	  |# 210859.so   
 |  	   	   	   	  var.tfacp240.vatc  =     
 |  	   	   	   	   	  get.country.of.financial.company(   
 |  	   	   	   	   	   	   	  current.company)   
 	   	   	   	   	   	   	   	  |# 210859.eo   
 	   	   	   	   	   	   	   	  |# 210859.so   
 |  	   	   	   	  get.tax.by.country.code(  	  |# 210859.sn   
 |  	   	   	   	   	   	  tdpur041.ccty,   
 |  	   	   	   	   	   	  tdpur041.cvat,   
 |  	   	   	   	   	   	  var.tfacp240.vatc,   
 |  	   	   	   	   	   	  var.tfacp240.cvat,   
 |  	   	   	   	   	   	  error.message) |# 210859.en   
 	   	   	   	   	   	   	   	  |# 210859.eo   
 	   	   	   	   	   	   	   	  |# 210859.sn   
 	   	   	   	  get.tax.by.country.code.and.financial.company(   
 	   	   	   	   	   	  tdpur041.ccty,   
 	   	   	   	   	   	  tdpur041.cvat,   
 	   	   	   	   	   	  current.company,   
 	   	   	   	   	   	  var.tfacp240.vatc,   
 	   	   	   	   	   	  var.tfacp240.cvat,   
 	   	   	   	   	   	  error.message) |# 210859.en   
 	   	   	  endif  	   	   	   	   	  |# SP2.en   
 	   	   	   	   	     
 	   	   	  prev.041.orno  =  tdpur041.orno   
 	   	   	  prev.041.pono  =  tdpur041.pono   
 	   	   	  g.prev.bqua  =  0.0  	   	  |# fp10.sn   
 	   	   	  g.prev.amld  =  0.0   
 	   	   	  g.prev.amod  =  0.0  	   	  |# fp10.en   
 	   	  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   
 	   	     
 	   	  select  	  bcswh010.*    	   	   	   	  |# FP10.sn   
 	   	  from  	  bcswh010   
 	   	  where  	  bcswh010._index1  =  {  	     
 	   	   	   	   	   	  tckoor.act.pur,   
 	   	   	   	   	   	  :tdpur045.orno,   
 	   	   	   	   	   	  :tdpur045.pono,   
 	   	   	   	   	   	  :tdpur045.srnb }   
 	   	  and  	  bcswh010._compnr  =  :logistic.company |# 1645612.n   
 	   	  order by bcswh010._index1   
 	   	  selectdo   
 	   	   	  g.use.mapping.table  =  true   
 	   	   	  handle.order.line()   
 	   	  selectempty   
 	   	   	  |   *  mapping table is empty for this record  ->  use   
 	   	   	  |   *  migration logic without mapping  -  table bcswh010   
 	   	   	  g.use.mapping.table  =  false   
 	   	   	  handle.order.line()   
 	   	  endselect  	   	   	   	   	   	   	  |# FP10.en   
 	   	  prev.bqua  =  tdpur045.bqua   
 	   	   	   	   	   	   	   	  |# fp10.so   
 |  	   	  prev.orno  =  tdpur045.orno   
 |  	   	  prev.pono  =  tdpur045.pono   
 	   	   	   	   	   	   	   	  |# fp10.eo   
 	   	     
 	   	     
 	   	     
 	   	   	   	   	   	   	   	  |# fp10.so   
 |  	   	  |   *  Next situations are possible:   
 |  	   	  |   *    -  One entry in tdpur045 for order  /  position   
 |  	   	  |   *    	    -  no.of.receipt.lines  =  0 (no receipts yet)   
 |  	   	  |   *    	    -  tdpur045.srnb  =  0   
 |  	   	  |   *    	    -  one record added to tfacp240   
 |  	   	  |   *    -  One entry in tdpur045 for order  /  position   
 |  	   	  |   *    	    -  no.of.receipt.lines  =  1 (1 receipt)   
 |  	   	  |   *    	    -  tdpur045.srnb  =  1   
 |  	   	  |   *    	    -  one record added to tfacp240   
 |  	   	  |   *    	    -  one record added to tfacp245   
 |  	   	  |   *    	    -  This is a collect order (order and receipt in once)   
 |  	   	  |   *    -  Two entries in tdpur045 for order  /  position   
 |  	   	  |   *    	    -  no.of.repeipt.lines  =  1 (first receipt)   
 |  	   	  |   *    	    -  one record added to tfacp240   
 |  	   	  |   *    	    -  one record added to tfacp245, if tdpur045.date  <>  0   
 |  	   	  |   *    -  More than two entries in tdpur045 for order  /  position   
 |  	   	  |   *    	  (backorders present)   
 |  	   	  |   *    	    -  no.of.receipt.lines  >=  2   
 |  	   	  |   *    	    -  one record added to tfacp240 (original order line)   
 |  	   	  |   *    	    -  one record added to tfacp240 for each backorder   
 |  	   	  |   *    	    -  for each record of tdpur045 with tdpur045.date  <>  0   
 |  	   	  |   *    	   	  (actual receipt date) a record is added to   
 |  	   	  |   *    	   	  tfacp245.   
 |  	   	  if no.of.receipt.lines  =  0 or tdpur045.srnb  >=  1 then   
 |  	   	   	  |   *  Original order line and the backorders are inserted   
 |  	   	   	  |   *  in tfacp240   
 |  	   	   	  |   *  Only if there is no receipt tfacp240 record is   
 |  	   	   	  |   *  added seperately. Else tfacp240 is inserted when   
 |  	   	   	  |   *  tfacp245 is inserted.   
 |  	   	   	  var.tfacp240.sqnb  =  get.order.line.sequence(   
 |  	   	   	   	   	   	  tdpur045.srnb)   
 |  	   	   	  var.tfacp240.otbp  =  get.business.partner.code(   
 |  	   	   	   	   	   	  tdpur040.suno,   
 |  	   	   	   	   	   	  bcstc.orgn.suno,   
 |  	   	   	   	   	   	  error.message)   
 |  	   	   	  |   *  Also used for ifbp and sfbp   
 |  	   	   	  var.tfacp240.proj  =  get.project.by.company(   
 |  	   	   	   	   	   	  tdpur045.cprj,   
 |  	   	   	   	   	   	  logistic.company)   
 |  	   	   	  if not isspace(tdpur045.cprj) then   
 |  	   	   	   	  var.tfacp240.bppr  =  get.baan.project(   
 |  	   	   	   	   	   	   	  logistic.company,   
 |  	   	   	   	   	   	   	  tdpur045.cprj)   
 |  	   	   	  else   
 |  	   	   	   	  var.tfacp240.bppr  =  tcyesno.no   
 |  	   	   	  endif  	     
 |  	   	   	  if tdpur045.srnb  <  2 then   
 |  	   	   	   	  |   *  Normal order   
 |  	   	   	   	  convert.quantity.from.order.unit.to.inventory.unit(   
 |  	   	   	   	   	  tdpur041.oqua,   
 |  	   	   	   	   	  var.tfacp240.iuni,   
 |  	   	   	   	   	  tdpur041.cvqp,   
 |  	   	   	   	   	  "",    
 |  	   	   	   	   	  "",    
 |  	   	   	   	   	  "tcqrd1",    
 |  	   	   	   	   	  var.tfacp240.oqan)   
 |  	   	   	  else   
 |  	   	   	   	  convert.quantity.from.order.unit.to.inventory.unit (   
 |  	   	   	   	   	  prev.bqua,   
 |  	   	   	   	   	  var.tfacp240.iuni,   
 |  	   	   	   	   	  tdpur041.cvqp,   
 |  	   	   	   	   	  "",    
 |  	   	   	   	   	  "",    
 |  	   	   	   	   	  "tcqrd1",    
 |  	   	   	   	   	  var.tfacp240.oqan)   
 |  	   	   	   	  |   *  Back order   
 |  	   	   	  endif  	     
 |  	   	   	  get.order.amount(var.tfacp240.oamt)   
 |  	   	   	  |   *  Calculate amount in home currencies   
 |  	   	   	  for element  =  1 to 3   
 |  	   	   	   	  ret.long  =  calculate.amount.in.home.currency(   
 |  	   	   	   	   	   	  var.tfacp240.oamt,   
 |  	   	   	   	   	   	  tdpur040.ccur,   
 |  	   	   	   	   	   	  tdpur040.ratp,   
 |  	   	   	   	   	   	  tdpur040.ratf,   
 |  	   	   	   	   	   	  element,   
 |  	   	   	   	   	   	  var.tfacp240.amth(element),   
 |  	   	   	   	   	   	  error.message)   
 |  	   	   	  endfor   
 |  	   	   	  |   *  In Baan IV only one receipt per order line.   
 |  	   	   	  |   *  Quantities can be taken from the receipt.   
 | |  	   	   	  if tcmcs042.reto  =  tcyesno.yes then  	  |# 207117.o   
 |  	   	   	   	   	   	   	   	  |# 207117.sn   
 |  	   	   	   	   	   	   	   	  |# 221043.sn   
 |  	   	   	  var.tfacp245.rcno  =  get.receipt.number()   
 |  	   	   	   	   	   	   	   	  |# 221043.en   
 |  	   	   	   	   	   	   	   	  |# 236822.sn   
 |  	   	   	  var.tfacp245.rseq  =  get.receipt.line()   
 |  	   	   	   	   	   	   	   	  |# 236822.en   
 |  	   	   	  if double.cmp(tdpur041.oqua, 0.0, 0.00001)  =    -  1 then   
 |  	   	   	   	   	   	   	   	  |# 207117.en   
 |  	   	   	   	   	   	   	   	  |# fp10.sn   
 |  	   	   	   	  if g.use.mapping.table then   
 |  	   	   	   	   	  g.quantity  =  bcswh010.qapr   
 |  	   	   	   	  else   
 |  	   	   	   	   	  g.quantity  =  tdpur045.quad   
 |  	   	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp10.en   
 |  	   	   	  |   *  Return order   
 |  	   	   	   	  convert.quantity.from.order.unit.to.inventory.unit (   
 | |  	   	   	   	   	   	  tdpur045.quad, |# fp10.o   
 |  	   	   	   	   	   	  g.quantity,  	  |# fp10.n   
 |  	   	   	   	   	   	  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,  	  |   *  Outbound Sequence  	  |# 243681.n   
 |  	   	   	   	   	  0,   
 |  	   	   	   	   	  error.message)  	  |   *  ref   
 | |  	   	   	   	   	   	   	   	  |# 221043.so   
 | |  	   	   	   	  var.tfacp245.rcno  =  bcswh008.shpm   
 | |  	   	   	   	   	   	   	   	  |# 215078.en   
 | |  	   	   	   	   	   	   	   	  |# 221043.eo   
 |  	   	   	  else   
 |  	   	   	   	   	   	   	   	  |# fp10.sn   
 |  	   	   	   	  if g.use.mapping.table then   
 |  	   	   	   	   	  g.quantity  =  bcswh010.qapr   
 |  	   	   	   	  else   
 |  	   	   	   	   	  g.quantity  =  tdpur045.quap   
 |  	   	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp10.en   
 |  	   	   	   	  convert.quantity.from.order.unit.to.inventory.unit (   
 | |  	   	   	   	   	   	  tdpur045.quap, |# fp10.o   
 |  	   	   	   	   	   	  g.quantity,  	  |# fp10.n   
 |  	   	   	   	   	   	  var.tfacp240.iuni,   
 |  	   	   	   	   	   	  tdpur041.cvqp,   
 |  	   	   	   	   	   	  "",    
 |  	   	   	   	   	   	  "",    
 |  	   	   	   	   	   	  "tcqrd1",    
 |  	   	   	   	   	   	  var.tfacp240.tapq)  	     
 |  	   	   	   	   	   	   	   	  |# fp10.sn   
 |  	   	   	   	  if g.use.mapping.table then   
 |  	   	   	   	   	  g.quantity  =  bcswh010.qrej   
 |  	   	   	   	  else   
 |  	   	   	   	   	  g.quantity  =  tdpur045.quad   
 |  	   	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp10.en   
 |  	   	   	   	  convert.quantity.from.order.unit.to.inventory.unit (   
 | |  	   	   	   	   	   	  tdpur045.quad, |# fp10.o   
 |  	   	   	   	   	   	  g.quantity,  	  |# fp10.n   
 |  	   	   	   	   	   	  var.tfacp240.iuni,   
 |  	   	   	   	   	   	  tdpur041.cvqp,   
 |  	   	   	   	   	   	  "",    
 |  	   	   	   	   	   	  "",    
 |  	   	   	   	   	   	  "tcqrd1",    
 |  	   	   	   	   	   	  var.tfacp240.trqu)   
 | |  	   	   	   	   	   	   	   	  |# 221043.so   
 | |  	   	   	   	  var.tfacp245.rcno  =  convert.number(   
 | |  	   	   	   	   	   	   	  bcckon.receipt.number,   
 | |  	   	   	   	   	   	   	  tdpur045.reno)   
 | |  	   	   	   	   	   	   	   	  |# 221043.eo   
 |  	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp10.sn   
 |  	   	   	  if g.use.mapping.table then   
 |  	   	   	   	  g.quantity  =  bcswh010.qrcv   
 |  	   	   	  else   
 |  	   	   	   	  g.quantity  =  tdpur045.dqua   
 |  	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp10.en   
 |  	   	   	  convert.quantity.from.order.unit.to.inventory.unit (   
 | |  	   	   	   	   	  tdpur045.dqua,  	  |# fp10.o   
 |  	   	   	   	   	  g.quantity,  	  |# fp10.n   
 |  	   	   	   	   	  var.tfacp240.iuni,   
 |  	   	   	   	   	  tdpur041.cvqp,   
 |  	   	   	   	   	  "",    
 |  	   	   	   	   	  "",    
 |  	   	   	   	   	  "tcqrd1",    
 |  	   	   	   	   	  var.tfacp240.rqty)   
 |  	   	   	     
 |  	   	   	  if (tdpur045.matc  =  tdpur.matc.complete) or   
 |  	   	   	  (tdpur045.stsd  =  tcstsd.all.approved) or | 223929.n   
 |  	   	   	  (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) |# 236822.o   
 |  	   	   	   	   	   	  tdpur045.srnb,  	  |# 236822.sn   
 |  	   	   	   	   	   	  var.tfacp245.rcno,   
 |  	   	   	   	   	   	  var.tfacp245.rseq) |# 236822.en   
 |  	   	   	  dump 3   
 |  	   	   	     
 |  	   	   	  if double.cmp(var.tfacp240.oqan, 0.0,0.000001)  =  0 then   
 |  	   	   	   	  var.tfacp249.gamt  =  var.tfacp240.oamt   
 |  	   	   	  else   
 |  	   	   	   	  var.tfacp249.gamt  =     
 |  	   	   	   	  (var.tfacp240.oamt  /  var.tfacp240.oqan)  *     
 |  	   	   	   	  var.tfacp240.tapq   
 |  	   	   	   	  tccri.dll0011.get.rounding.code(   
 |  	   	   	   	   	  tdpur040.ccur,   
 |  	   	   	   	   	  var.inv.crnd)   
 |  	   	   	   	  var.tfacp249.gamt  =  icom0001.domain.round(   
 |  	   	   	   	   	  var.tfacp249.gamt,   
 |  	   	   	   	   	  "tfgld.amnt",    
 |  	   	   	   	   	  tdpur040.ccur,   
 |  	   	   	   	   	  var.inv.crnd)   
 |  	   	   	   	  endif  	   	   	   	   	   	   	   	     
 |  	   	   	  dump 4   
 |  	   	  endif  	     
 	   	   	   	   	   	   	   	  |# fp10.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:F
:QURY:START
	  free.mem(s.array.receipt.line)  	   	   	   	  |# 1019539.n
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:240
:SCPAC:td
:SCMOD:pur
:SFLNO:045
:ICOD:X
:QURY:START
| endselect  	   	   	   	   	   	   	  |# 239888.o
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:046
:ICOD:D
:QURY:START
	   	  if not get.invoice.related.data() then  	  |# 217083.sn   
 	   	   	  continue   
 	   	  endif  	   	   	   	   	   	  |# 217083.en   
 	   	   	   	   	   	   	   	   	  |# FP10.sn   
 	   	  select  	  bcswh010.*     
 	   	  from  	  bcswh010   
 	   	  where  	  bcswh010._index1  =  {  	     
 	   	   	   	   	   	  tckoor.act.pur,   
 	   	   	   	   	   	  :tdpur045.orno,   
 	   	   	   	   	   	  :tdpur045.pono,   
 	   	   	   	   	   	  :tdpur045.srnb }   
 	   	  and  	  bcswh010._compnr  =  :logistic.company |# 1645612.n   
 	   	  order by bcswh010._index1   
 	   	  selectdo   
 	   	   	  g.use.mapping.table  =  true   
 	   	   	  handle.matched.invoice()   
 	   	  selectempty   
 	   	   	  |   *  mapping table is empty for this record  ->  use   
 	   	   	  |   *  migration logic without mapping  -  table bcswh010   
 	   	   	  g.use.mapping.table  =  false   
 	   	   	  handle.matched.invoice()   
 	   	  endselect  	   	   	   	   	   	  |# FP10.en   
 	   	   	   	   	   	   	   	  |# fp10.so   
 |  	   	  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)  	  |# 217083.o   
 |  	   	  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  	   	   	   	  |# 217083.so   
 | |  	   	   	  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  	   	   	   	   	   	  |# 217083.eo   
 | |  	   	  if tcmcs042.reto  =  tcyesno.yes then  	   	  |# 207117.o   
 |  	   	   	   	   	   	   	   	  |# 249604.so   
 | |  	   	   	   	   	   	   	   	  |# 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,  	  |   *  Outbound Sequence  	  |# 243681.n   
 | |  	   	   	   	   	  0,   
 | |  	   	   	   	   	  error.message)  	   	  |   *  ref   
 | |  	   	   	  var.tfacp251.rcno  =  bcswh008.shpm  	  |# 215078.en   
 | |  	   	  else   
 | |  	   	   	  var.tfacp251.rcno  =  convert.number(   
 | |  	   	   	   	   	   	  bcckon.receipt.number,   
 | |  	   	   	   	   	   	  tdpur045.reno)   
 | |  	   	  endif  	   	     
 |  	   	   	   	   	   	   	   	  |# 249604.eo   
 |  	   	   	   	   	   	   	   	  |# 249604.sn   
 |  	   	  var.tfacp251.rcno  =  get.receipt.number()   
 |  	   	  var.tfacp251.rseq  =  get.receipt.line()  	  |# fp10.n   
 |  	   	   	   	   	   	   	   	  |# 249604.en   
 |  	   	  var.tfacp250.sqnb  =  get.order.line.sequence( |# 322471.sn   
 |  	   	   	   	   	   	  tdpur045.srnb)  	  |# 322471.en   
 |  	   	  |   *  Only 1 receipt per order line.   
 |  	   	  dump 1   
 |  	   	  dump 2   
 |  	   	  |# migr fp5 sn   
 |  	   	  dump 3   
 |  	   	  |# migr fp5 en   
 	   	   	   	   	   	   	   	  |# fp10.eo   
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:046
:ICOD:S
:QURY:START
select tdpur046.*  ,  	     
 |  	   	   	   	   	   	   	   	  |# 217083.so   
 |  	   	  tfacp200.ccur, tfacp200.rate, tfacp200.ratf, tfacp200.docd,   
 |  	   	  tfacp200.tapr, tfacp200.dapr,  	   	   	  |# 217083.eo   
 |  	   	  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   
 	   	  tdpur045.matc, tdpur045.dqua, tdpur045.quap,  	  |# 217083.sn   
 	   	  tdpur045.quad  	   	   	   	   	  |# 217083.en   
 |  	  from  	  tdpur046, tfacp200, tdpur041, tiitm001, tdpur045 |# 208878.o   
 |  	   	   	   	   	   	   	   	  |# 217083.so   
 |  	  from  	  tdpur046, tfacp200, tdpur041, tdpur045  	  |# 208878.n   
 |  	   	   	   	   	   	   	   	  |# 217083.eo   
 	    
from 	  tdpur046, tdpur041, tdpur045  	   	   	  |# 217083.n   
 	
where 	  tdpur046._compnr  =  :logistic.company   
 	  and  	  tdpur041._compnr  =  :logistic.company   
 	  and  	  tdpur045._compnr  =  :logistic.company   
 |  	  and  	  tfacp200._compnr  =  :current.company  	   	  |# 217083.so   
 |  	  and  	  tfacp200._index1  =  {tdpur046.ttyp, tdpur046.invn}   
 |  	  and  	  tfacp200.tdoc  =  ""    
 |  	  and  	  tfacp200.docn  =  0  	   	   	   	  |# 217083.eo   
 	   	  |   *  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  	   	   	     
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:250
:SCPAC:td
:SCMOD:pur
:SFLNO:046
:ICOD:X
:QURY:START
| endselect  	   	   	   	   	   	   	  |# 239888.o
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:002
:SCPAC:tf
:SCMOD:acr
:SFLNO:002
:ICOD:S
:QURY:START
select tfacr002.*   
from tfacr002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:002
:SCPAC:tf
:SCMOD:acr
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:005
:SCPAC:tf
:SCMOD:acr
:SFLNO:005
:ICOD:D
:QURY:START
	 	 	 	 	 	 	 	 | #  250988.sn  
 	 acct.type =  get.parent.or.dependent(tfacr005.tran)  
 	 if acct.type =  "independent" then                                                                                                                                                                                                                                                                                                                                                                    
 	 	 var.tfacr005.dim(1,1) =  tfacr005.dim1  
 	 	 var.tfacr005.dim(1,2) =  tfacr005.dim2  
 	 	 var.tfacr005.dim(1,3) =  tfacr005.dim3  
 	 	 var.tfacr005.dim(1,4) =  tfacr005.dim4  
 	 	 var.tfacr005.dim(1,5) =  tfacr005.dim5  
 	 else  
 	 	 get.dim.options(tfacr005.leac, child.dim.opt)  
 	 	 get.child.dimensions.from.source()  
 	 	 fill.child.dimensions.in.target (tfacr005.tran)  
 	 endif  
 	 	 	 	 	 	 	 	 | #  250988.en  
 	 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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:005
:SCPAC:tf
:SCMOD:acr
:SFLNO:005
:ICOD:S
:QURY:START
select tfacr005.*
from tfacr005
order by tfacr005._index1 	 	 	 	 	 | #  1040916.n
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:200
:SCPAC:tf
:SCMOD:acr
:SFLNO:200
:ICOD:D
:QURY:START
	   	   	   	   	   	   	  |# 200  -  101927.sn   
 	  initialize.variables()   
 	  fill.positive.amounts.invoice()   
 	   	   	   	   	   	   	  |# 148886.so  	   	     
 |  	  if tfacr200.trec  =  tfacr.trec.credit and tfacr200.amnt  >  0 then   
 |  	   	  fill.negative.amounts.credit.note()   
 |  	  endif   
 	   	   	   	   	   	   	  |# 148886.eo   
 	   	   	   	   	   	   	  |# 200  -  101927.en   
 	  if tfacr200.vatp  =  0 or tfacr200.vaty  =  0 then   
 	   	  itfgld0012.get.year.prno.from.date( get.compnr(),   
 	   	   	   	   	   	  tfgld.ptyp.vat,   
 	   	   	   	   	   	  tfacr200.docd)   
 	   	  vat.year  =  igld0012.year   
 	   	  vat.prod  =  igld0012.prno   
 	  else   
 	   	  vat.year  =  tfacr200.vaty   
 	   	  vat.prod  =  tfacr200.vatp   
 	  endif   
 	   	   	   	   	   	   	   	     
 	  new.country  =  ""    
 	  new.tax  =  ""    
 	   	   	   	   	   	   	   	  |# 210859.so   
 |  	   	  get.tax.by.country.code(   
 |  	   	   	  tfacr200.vatc,   
 |  	   	   	  tfacr200.cvat,   
 |  	   	   	  new.country,   
 |  	   	   	  new.tax,   
 |  	   	   	  var.err.mess)   
 	   	   	   	   	   	   	   	  |# 210859.eo   
 	   	   	   	   	   	   	   	  |# 210859.sn   
 	  if tfacr200.lvat  =  tfacp.vatc.header then  	   	  |# 1359481.n   
 	   	  get.tax.by.country.code.and.financial.company(   
 	   	   	  tfacr200.vatc,   
 	   	   	  tfacr200.cvat,   
 	   	   	  get.compnr(),   
 	   	   	  new.country,   
 	   	   	  new.tax,   
 	   	   	  var.err.mess)   
 	  endif  	   	   	   	   	   	   	  |# 1359481.n   
 	   	   	   	   	   	   	   	  |# 210859.en   
 	  if (tfacr200.spot  =  tcyesno.yes) then   
 |  	   	  var.tfacr200.rade  =  1  	  |# 200704.o   
 	   	  var.tfacr200.rade  =  10  	  |# 200704.n   
 	  else   
 	   	  var.tfacr200.rade  =  6  	     
 	  endif   
 	  var.str.temp.key (1;6)  =  tfacr200.cuno   
 	  var.str.temp.key (7;9)  =  tfacr200.adrs   
 	   	   	   	   	   	   	   	  |# ms.so  	   	     
 |  	  if determine.bccnv901.address ("tccom012",var.str.temp.key)  =  0 then   
 |  	   	  bccnv901.cadr  =  empty.string (1;9)   
 |  	  endif   
 |  	  var.str.bpid  =  get.bpid (tfacr200.cuno,bccom.orgn.cuno)  	     
 	   	   	   	   	   	   	   	  |# ms.eo   
 	     
 	  if not get.addresses("tccom012", var.str.temp.key,var.err.mess) then   
 	   	  var.tfacr200.adrs  =  bcstc004.cadr   
 	  else   
 |  	   	   	  var.tfacr200.adrs  =  ""  	   	  |# 243958.o    
 	   	   	   	   	   	   	  |# 243958.sn   
 	   	  if not get.addresses("tccom010", var.str.temp.key,var.err.mess) then   
 	   	   	  var.tfacr200.adrs  =  bcstc004.cadr   
 	   	  else   
 	   	   	  var.tfacr200.adrs  =  ""    
 	   	  endif   
 	   	   	   	   	   	   	  |# 243958.en   
 	  endif   
 	     
 	  if not get.business.partner(tfacr200.cuno,bcstc.orgn.cuno,var.err.mess) then   
 	   	  var.str.bpid  =  bcstc008.bpid   
 	  else   
 	   	  var.str.bpid  =  ""    
 	  endif   
 	   	   	   	   	   	   	   	  |# FP3.sn   
 	  fill.tfacr200.pysh()   
 	  if tfacr200.trec  =  tfacr.trec.invoice or tfacr200.trec  =  tfacr.trec.credit or   
 	   	  tfacr200.trec  =  tfacr.trec.advance or tfacr200.trec  =  tfacr.trec.unallocated then   
 	   	  fill.tfacr200.leac()   
 	  else   
 	   	  var.tfacr200.leac  =  ""    
 	   	  var.dimension1  =  ""  	   	  |# 1056135.sn    
 	   	  var.dimension2  =  ""  	   	     
 	   	  var.dimension3  =  ""  	   	     
 	   	  var.dimension4  =  ""  	   	     
 	   	  var.dimension5  =  ""  	   	  |# 1056135.sn    
 	  endif   
 	   	   	   	   	   	   	   	  |# FP3.en   
 	   	   	   	   	   	   	  |# 235153.sn   
 	  if isspace(tfacr200.tdoc) or tfacr200.docn  =  0 then   
 	   	  select  	  tfgld018.*     
 	   	  from  	  tfgld018   
 	   	  where  	  tfgld018._index1  =  { :tfacr200.ttyp, :tfacr200.ninv }   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	   	  var.tfacr200.post  =  tfgld018.trun   
 	   	   	  var.tfacr200.pdat  =  tfgld018.date   
 	   	  endselect   
 	  else   
 	   	  select  	  tfgld018.*     
 	   	  from  	  tfgld018   
 	   	  where  	  tfgld018._index1  =  { :tfacr200.tdoc, :tfacr200.docn }   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	   	  var.tfacr200.post  =  tfgld018.trun   
 	   	   	  var.tfacr200.pdat  =  tfgld018.date   
 	   	  endselect   
 	  endif   
 	   	   	   	   	   	   	   	  |# 235153.en   
 	   	     
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	  get.step()   
 	  if etol(tfacr200.cain)  =  0 then   
 	   	  var.tfacr200.cain  =  2  	     
 	  else   
 	   	  var.tfacr200.cain  =  etol(tfacr200.cain)   
 	  endif   
 	  if etol(tfacr200.lvat)  =  0 then   
 	   	  var.tfacr200.lvat  =  2   
 	  else   
 	   	  var.tfacr200.lvat  =  etol(tfacr200.lvat)   
 	  endif   
 	  get.receipt.info(   
 	   	  var.tfacr200.rcom,  	   	     
 	   	  var.tfacr200.rect,   
 	   	  var.tfacr200.recd,   
 	   	  var.tfacr200.recl)   
 	   	   	   	   	   	   	   	  |# FP7.en   
 	  dump 1   
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	  if isspace(tfacr200.tdoc) then   
 	   	  var.tfacr500.toba  =  tfacr200.balc  -  tfacr200.bala   
 	   	  if double.cmp(var.tfacr500.toba, 0.0, 0.0001)  =  0 then   
 	   	   	  var.tfacr500.flpd  =  tcyesno.yes   
 	   	  else   
 	   	   	  var.tfacr500.flpd  =  tcyesno.no   
 	   	  endif   
 	  	 get.customer.fin.business.partner.group( 	  	 |#Migr. 10.6.sn   
 	  	  	  	 current.company,   
 	  	  	  	 tfacr200.cuno,   
 	  	  	  	 var.tfacr500.ficu) 	 |  *  ref 	 |#Migr. 10.6.en   
 	   	  dump 2  	     
 	  endif   
 	   	   	   	   	   	   	   	  |# FP7.en
:QURY:END
:TEXT:

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:301
:SCPAC:tf
:SCMOD:acr
:SFLNO:301
:ICOD:S
:QURY:START
select tfacr301.*    
from tfacr301
:QURY:END
:TEXT:
tfacr301 does not have any conversion logic to be implemented. 
Source table is selected  and directly it is put in target table.
:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:301
:SCPAC:tf
:SCMOD:acr
:SFLNO:301
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:305
:ICOD:S
:QURY:START
select tfacr305.*   
from tfacr305
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:305
:SCPAC:tf
:SCMOD:acr
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:312
:SCPAC:tf
:SCMOD:acr
:SFLNO:312
:ICOD:D
:QURY:START
if isspace(tfacr312.agan) then  
 	 	 fill.default.agan()  
 	 else  
 	 	 var.tfacr312.agan =  tfacr312.agan  
 	 endif  
 dump 999
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:312
:SCPAC:tf
:SCMOD:acr
:SFLNO:312
:ICOD:S
:QURY:START
select tfacr312.*
from tfacr312
:QURY:END
:TEXT:
Existing rule is sufficient. No new logic added.
:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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 |   *  tfcmg000  -  CMG Parameters   
 	  var.tfcmg000.indt  =  utc(date.num(),time.num())   
 	  var.tfcmg000.desc  =  form.text$("bcstc00036") |   *  Converted from Baan IVc4   
 	  dump 1 |   *  tfcmg000  -  CMG Parameters
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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  	   	  |   *  tfcmg001  -  Bank Relations
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:D
:QURY:START
new.country  =  ""    
 	  new.tax  =  ""    
 	   	   	   	   	   	   	  |# 210859.so   
 |  	  get.tax.by.country.code(tfcmg101.vatc, tfcmg101.cvat, new.country,   
 |  	   	   	  new.tax, var.str.err.mess)   
 	   	   	   	   	   	   	  |# 210859.eo   
 	   	   	   	   	   	   	  |# 210859.sn   
 	  get.tax.by.country.code.and.financial.company(   
 	   	   	  tfcmg101.vatc, tfcmg101.cvat, tfcmg101.comp,   
 	   	   	  new.country, new.tax, var.str.err.mess)   
 	   	   	   	   	   	   	  |# 210859.en   
 |  	  var.tfcmg101.adty  =  0  	   	   	   	  |# FP7.o   
 	  var.tfcmg101.adty  =  target(tfcmg.adty.not.appl)  	  |# FP7.n   
 	  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  	   	  |# FP7.o   
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	   	   	  var.tfcmg101.adty  =  target(tfcmg.adty.tang.assets)   
 	   	   	   	   	   	   	   	  |# FP7.en   
 	   	  case tfcmg.tadv.unallocated:   
 	   	  case tfcmg.tadv.standing:   
 	   	   	  if standing.is.advance() then   
 |  	   	   	   	  var.tfcmg101.adty  =  1  	  |# FP7.o   
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	   	   	   	  var.tfcmg101.adty  =  target(tfcmg.adty.tang.assets)   
 	   	   	   	   	   	   	   	  |# FP7.en   
 	   	   	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:D
:QURY:START
	  new.country  =  ""   
 	  new.tax  =  ""   
 	    	    	    	    	    	    	    	   | # 210859.so   
 |   	  get.tax.by.country.code(   
 |   	    	    	  tfcmg111.vatc,   
 |   	    	    	  tfcmg111.cvat,   
 |   	    	    	  new.country,   
 |   	    	    	  new.tax,   
 |   	    	    	  err.mess)   
 	    	    	    	    	    	    	    	   | # 210859.eo   
 	    	    	    	    	    	    	    	   | # 210859.sn   
 	  get.tax.by.country.code.and.financial.company(   
 	    	    	  tfcmg111.vatc,   
 	    	    	  tfcmg111.cvat,   
 	    	    	  tfcmg111.cono,   
 	    	    	  new.country,   
 	    	    	  new.tax,   
 	    	    	  err.mess)   
 	    	    	    	    	    	    	    	   | # 210859.en   
 |   	  var.tfcmg111.adty  =  0  	    	    	   | # ravi.n  	   | # FP7.o   
 	  var.tfcmg111.adty  =  target(tfcmg.adty.not.appl)  	    	   | # FP7.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  	    	    	   | # FP7.o   
 	    	    	    	    	    	    	    	   | # FP7.sn   
 	    	    	  var.tfcmg111.adty  =  target(tfcmg.adty.tang.assets)   
 	    	    	    	    	    	    	    	   | # FP7.en   
 	    	  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 |   *  tfcmg111  -  Anticipated Payments  /  Receipts (Details)
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:D
:QURY:START
	  new.country  =  ""   
 	  new.tax  =  ""   
 	   	   	   	   	   	   	   	  |# 210859.so   
 |  	  get.tax.by.country.code(   
 |  	   	   	  tfcmg204.vatc,   
 |  	   	   	  tfcmg204.cvat,   
 |  	   	   	  new.country,   
 |  	   	   	  new.tax,   
 |  	   	   	  err.mess)   
 	   	   	   	   	   	   	   	  |# 210859.eo   
 	   	   	   	   	   	   	   	  |# 210859.sn   
 	  get.tax.by.country.code.and.financial.company(   
 	   	   	  tfcmg204.vatc,   
 	   	   	  tfcmg204.cvat,   
 	   	   	  current.company,   
 	   	   	  new.country,   
 	   	   	  new.tax,   
 	   	   	  err.mess)   
 	   	   	   	   	   	   	   	  |# 210859.en   
 |  	  var.tfcmg204.adty  =  0  	   	   	   	   	  |# FP7.o   
 	  var.tfcmg204.adty  =  target(tfcmg.adty.not.appl)  	   	  |# FP7.n   
 	  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  	   	   	   	  |# FP7.o   
 	   	   	   	   	   	   	   	  |# FP7.sn   
 	   	  var.tfcmg204.adty  =  target(tfcmg.adty.tang.assets)   
 	   	   	   	   	   	   	   	  |# FP7.en   
 	   	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:000
:SCPAC:tf
:SCMOD:fas
:SFLNO:001
:ICOD:D
:QURY:START
get.data.from.tffas203()  	   	   	   	  |# 213701.n   
 var.tffam000.indt  =  utc(0, 0)   
 var.str.tffam000.dsca  =  form.text$("bcstc00035") |   *  Actual Set   
 dump 1   
 var.tffam000.indt  =  utc(date.num(), time.num())   
 var.str.tffam000.dsca  =  form.text$("bcstc00036") |   *  Converted from Baan IVc4   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:000
:SCPAC:tf
:SCMOD:fas
:SFLNO:001
:ICOD:S
:QURY:START
select tffas001.*     
from tffas001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:000
:SCPAC:tf
:SCMOD:fas
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:100
:SCPAC:tf
:SCMOD:fas
:SFLNO:007
:ICOD:D
:QURY:START
| # 200  -  100961.sn   
 	  if tffas007.fudt  <>  0 then   
 	    	  itfgld0012.get.year.prno.from.date( get.compnr(),   
 	    	    	    	    	    	  tfgld.ptyp.financial,   
 	    	    	    	    	    	  tffas007.fudt)   
 	    	  acc.year  =  igld0012.year   
 	    	  acc.prod  =  igld0012.prno   
 	  else   
 	    	  acc.year  =  0   
 	    	  acc.prod  =  0   
 	  endif   
 	    	    	    	    	    	    	   | # 200  -  100961.en   
 	    	    	    	    	    	    	   | # 200  -  100959.sn   
 	  get.pur.inv.no.from.tffas100()   
 	    	    	    	    	    	    	   | # 200  -  100959.sn   
 	    	    	    	    	    	    	     
 	  var.tffam100.stat  =  0   
 	  if isspace(tffas007.suno) then  	    	    	    	    	   | # 241014.sn   
 	    	   | # do not search in mapping table when suno is empty. This prevents an   
 	    	   | # error message in the logging.   
 	    	  var.tffam100.bpid  =  ""     
 	  else  	    	    	    	    	    	    	    	     
 	    	  if get.business.partner(tffas007.suno,bcstc.orgn.suno,var.str.err.mess) then   
 	    	    	   | # The field suno is filled but there could no mapping record be found.   
 	    	    	   | # an error message is logged.   
 	    	    	  var.tffam100.bpid  =  ""     
 	    	  else   
 	    	    	  var.tffam100.bpid  =  bcstc008.bpid   
 	    	  endif   
 	  endif  	    	    	    	    	    	    	    	   | # 241014.en   
 |   	  get.business.partner(tffas007.suno,bcstc.orgn.suno,var.str.err.mess)  	   | # 241014.o   
 	     
 |   *  If leased Asset  =  No then owner code is 'Owned (1)' otherwise owner code is 'Operating Lease(2)'   
 	  if tffas007.leas  =  tcyesno.no then   
 	    	  var.lng.tffam100.ownc  =  1   
 	  else   
 	    	  var.lng.tffam100.ownc  =  2   
 	  endif   
 |   *  If Transfer Date is empty then Reference Company, Reference Asset Number values are set to   
 |   *  empty and the Transfered Value is also set to NO   
 	    	    	    	    	    	   | # 200  -  100985.so   
 |   	  if tffas007.trdt  =  0 then   
 |   	    	  var.tffam100.trfg  =  tcyesno.no   
 |   	    	  var.lng.tffam100.rcmp  =  0   
 |   	    	  var.str.tffam100.rnbr  =  empty.string (1;15)   
 |   	  else  	    	     
 |   	    	  var.tffam100.trfg  =  tcyesno.yes   
 |   	    	  var.lng.tffam100.rcmp  =  ext.lng.comp   
 |   	    	  var.str.tffam100.rnbr  =  tffas007.ofas   
 |   	  endif  	    	    	    	    	   | # 200  -  100985.eo   
 	  stat.filled  =  false  	    	    	   | # 200  -  100985.sn   
 	  if tffas007.trdt  <>  0 then   
 	    	  read.transfered.asset()   
 	    	  var.str.tffam100.rnbr  =  tffas103.fasc   
 	    	  var.tffam100.trfg  =  tcyesno.yes   
 	    	  var.lng.tffam100.rcmp  =  ext.lng.comp   
 	    	  var.tffam100.rext  =  bcstf000.asex   
 	    	  var.tffam100.stat  =  3   
 	    	  stat.filled  =  true   
 	  else   
 	    	  if tffas007.ofas  <>  tffas007.fasc then   
 	    	    	  var.str.tffam100.rnbr  =  tffas007.ofas   
 	    	    	  var.tffam100.trfg  =  tcyesno.yes   
 	    	    	  var.lng.tffam100.rcmp  =  ext.lng.comp   
 	    	    	  var.tffam100.rext  =  bcstf000.asex   
 	    	    	  if check.record.existin.tffas101.tffas103() then | # 227065.sn   
 	    	    	    	  var.tffam100.stat  =  3   
 	    	    	  else  	    	    	    	    	   | # 227065.en   
 	    	    	    	  var.tffam100.stat  =  2   
 	    	    	  endif  	    	    	    	    	   | # 227065.n   
 	    	    	  stat.filled  =  true   
 	    	  else   
 	    	    	  var.str.tffam100.rnbr  =  empty.string (1;15)   
 	    	    	  var.tffam100.trfg  =  tcyesno.no   
 	    	    	  var.lng.tffam100.rcmp  =  0   
 	    	    	  var.tffam100.rext  =  empty.string(1;15)   
 	    	    	  stat.filled  =  false   
 	    	  endif   
 	  endif  	    	    	    	    	   | # 200  -  100985.en   
 |   *  Filling of Salvage Value   
 |   	  select  	  tffas008.rema  	    	    	    	   | # 209446.o   
 	  select tffas008.fasc, tffas008.depc, tffas008.rema,  	   | # 209446.sn   
 |   	    	    	  tffas008.rpoa, tffas008.remp  	    	   | # 209446.en | gsk.o   
 	    	  tffas008.rpoa, tffas008.remp,tffas008.dlas  	   | gsk.n   
 	  from  	  tffas008   
 	  where  	  tffas008.fasc  =  :tffas007.fasc   
 	  and  	  tffas008.depc  =  :tffas001.fdpc   
 	  as set with 1 rows   
 	  selectdo   
 |   	    	  var.tffam100.salv  =  tffas008.rema  	    	   | # 209446.o   
 	    	    	    	    	    	    	    	   | # 209446.sn   
 	    	    	  if tffas008.rpoa  =  tcyesno.yes then  	    	     
 	    	    	    	  var.tffam100.salv  =  tffas007.pval  *  (tffas008.remp  /  100)   
 	    	    	  else  	    	     
 	    	    	    	  var.tffam100.salv  =  tffas008.rema   
 	    	    	  endif  	    	    	    	    	    	   | # 209446.en   
 	    	    	  if tffas007.leas  =  tcyesno.yes  	   | gsk.sn   
 	    	    	  and tffas008.dlas  =  tcyesno.yes then   
 	    	    	    	  var.lng.tffam100.ownc  =  3   
 	    	    	  endif  	    	    	    	    	   | gsk.en   
 	    	     
 	  selectempty   
 |   	    	  select  	  tffas005.rema  	    	    	    	    	   | # 209446.o   
 	    	  select tffas005.ngrp, tffas005.depc, tffas005.rema, | # 209446.sn   
 |   	    	    	    	  tffas005.rpoa, tffas005.remp  	    	   | # 209446.en | gsk.o   
 	    	    	    	  tffas005.rpoa, tffas005.remp,tffas005.dlas  	   | gsk.n   
 	    	  from  	  tffas005   
 	    	  where  	  tffas005.ngrp  =  :tffas007.ngrp   
 	    	  and  	  tffas005.depc  =  :tffas001.fdpc   
 	    	  as set with 1 rows   
 	    	  selectdo   
 |   	    	    	  var.tffam100.salv  =  tffas005.rema  	    	   | # 209446.o   
 	    	    	  if tffas005.rpoa  =  tcyesno.yes then  	   | # 209446.sn   
 	    	    	    	    	  var.tffam100.salv  =  tffas007.pval  *  (tffas005.remp  /  100)   
 	    	    	    	  else  	    	     
 	    	    	    	    	  var.tffam100.salv  =  tffas005.rema   
 	    	    	    	  endif  	    	    	    	    	   | # 209446.en   
 	    	    	  if tffas007.leas  =  tcyesno.yes  	   | gsk.sn   
 	    	    	  and tffas005.dlas  =  tcyesno.yes then   
 	    	    	    	  var.lng.tffam100.ownc  =  3   
 	    	    	  endif  	    	    	    	    	   | gsk.en   
 	    	  selectempty   
 |   	    	    	  select tffas002.rema  	    	    	   | # 209446.o   
 |   	    	    	  select tffas002.depc, tffas002.rema, tffas002.rpoa, tffas002.remp | # 209446.n | gsk.o   
 	    	    	  select tffas002.depc, tffas002.rema, tffas002.rpoa, tffas002.remp,tffas002.dlas | gsk.n   
 	    	    	  from tffas002   
 	    	    	  where tffas002.depc  =  :tffas001.fdpc   
 	    	    	  as set with 1 rows   
 	    	    	  selectdo   
 |   	    	    	    	  var.tffam100.salv  =  tffas002.rema  	    	   | # 209446.o   
 	    	    	    	  if tffas002.rpoa  =  tcyesno.yes then  	   | # 209446.sn   
 	    	    	    	    	  var.tffam100.salv  =  tffas007.pval  *  (tffas002.remp  /  100)   
 	    	    	    	  else  	    	     
 	    	    	    	    	  var.tffam100.salv  =  tffas002.rema   
 	    	    	    	  endif  	    	    	    	    	   | # 209446.en   
 	    	    	    	  if tffas007.leas  =  tcyesno.yes  	   | gsk.sn   
 	    	    	    	  and tffas002.dlas  =  tcyesno.yes then   
 	    	    	    	    	  var.lng.tffam100.ownc  =  3   
 	    	    	    	  endif  	    	    	    	    	   | gsk.en  	     
 	    	    	    	     
 	    	    	  endselect   
 	    	  endselect   
 	  endselect   
 |   *  Original Quantity   
 	  if tffas007.quan  >  0 then   
 	    	  var.lng.tffam100.qty  =  tffas007.quan   
 	  else   
 	    	  var.lng.tffam100.qty  =  1   
 	  endif   
 |   *  Purcahse Date   
 	  if tffas007.ordt  =  0 then   
 	    	  var.str.fudt  =  utc (tffas007.fudt,0,2)   
 	  else   
 	    	  var.str.fudt  =  utc (tffas007.ordt,0,2)   
 	  endif  	     
 	    	    	    	    	    	    	   | # 200  -  98001.sn   
 	  if stat.filled  =  false then   
 	  select  	  tffas020.fasc, tffas020.type   
 	  from  	  tffas020   
 	  where  	  tffas020.fasc  =  :tffas007.fasc   
 	    	  and tffas020.type  =  tffas.type.investment   
 	  as set with 1 rows   
 	  selectdo   
 	    	  select  	  tffas101.fasc   
 	    	  from  	  tffas101   
 	    	  where  	  tffas101._index2  =  {:tffas007.fasc}   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  var.tffam100.stat  =  3   
 	    	  selectempty   
 	    	    	  var.tffam100.stat  =  2   
 	    	  endselect   
 	    	     
 	  selectempty   
 	    	  var.tffam100.stat  =  1   
 	  endselect   
 	  endif   
 	    	    	    	    	    	    	    	   | # 200  -  98001.en  	     
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:100
:SCPAC:tf
:SCMOD:fas
:SFLNO:007
:ICOD:S
:QURY:START
select tffas007.*   
from tffas007   
 | where NOT EXISTS (select tffas101.*    	    	    	   | # 200  -  98001.so   
 |   	    	  from tffas101   
 |   	    	  where tffas101.fasc  =  tffas007.fasc)  	   | # 200  -  98001.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:100
:SCPAC:tf
:SCMOD:fas
:SFLNO:007
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:110
:SCPAC:tf
:SCMOD:fas
:SFLNO:007
:ICOD:D
:QURY:START
	 var.tffam110.post  =  2 	  	 |# 222897.n   
 |select tffas008.rema 	  	  	  	  	  	 |# 209446.so   
 | 	 from tffas008   
 | 	 where tffas008.fasc  =  :tffas007.fasc and tffas008.depc  =  :tffas001.fdpc   
 | 	 as set with 1 rows   
 | 	 selectdo   
 | 	  	 var.tffam110.salv  =  tffas008.rema   
 | 	 selectempty   
 | 	  	 select tffas005.rema   
 | 	  	 from tffas005   
 | 	  	 where tffas005.ngrp  =  :tffas007.ngrp and tffas005.depc  =  :tffas001.fdpc   
 | 	  	 as set with 1 rows   
 | 	  	 selectdo   
 | 	  	  	 var.tffam110.salv  =  tffas005.rema   
 | 	  	 selectempty   
 | 	  	  	 select tffas002.rema   
 | 	  	  	 from tffas002   
 | 	  	  	 where tffas002.depc  =  :tffas001.fdpc   
 | 	  	  	 as set with 1 rows   
 | 	  	  	 selectdo   
 | 	  	  	  	 var.tffam110.salv  =  tffas002.rema   
 | 	  	  	 endselect   
 | 	  	 endselect   
 | 	 endselect   
 | 	 select tffas002.depc 	  	  	  	 |# 209446.eo   
 | 	 select tffas002.depc, tffas002.rema, tffas002.rpoa, tffas002.remp |# 209446.n |# 221360.o   
 	 select tffas002.depc, tffas002.rema, tffas002.rpoa, tffas002.remp, tffas002.codp |# 221360.n   
 	 from tffas002   
 	 selectdo   
 	  	 var.tffam110.ecre  =  2 	  	  	  	 |# 221360.n   
 | 	  	 select tffas008.fasc, tffas008.depc 	 |# 209446.o   
 	  	 select tffas008.fasc, tffas008.depc, tffas008.rema, 	 |# 209446.sn   
 | 	  	  	 tffas008.rpoa, tffas008.remp 	  	  	 |# 209446.en |# 221360.o   
 	  	  	 tffas008.rpoa, tffas008.remp, tffas008.codp 	  	 |# 221360.n   
 	  	 from tffas008   
 	  	 where tffas008.depc  =  :tffas002.depc and tffas008.fasc  =  :tffas007.fasc   
 	  	 as set with 1 rows   
 	  	 selectdo   
 	  	  	 var.tffam110.book  =  tffas008.depc   
 	  	  	  	  	  	  	  	 |# 222897.sn   
 	  	  	 if var.tffam110.book  <>  tffas001.fdpc then   
 	  	  	  	 var.tffam110.post  =  2   
 	  	  	 else   
 	  	  	  	 var.tffam110.post  =  1   
 	  	  	 endif 	  	  	  	  	 |# 222897.en   
 | 	  	  	 var.tffam110.meth  =  get.string(33)  &  tffas008.fasc  &  get.string(33)  &  tffas008.depc 	 |# 209317.o   
 	  	  	 var.tffam110.meth  =  get.string(32)  &  tffas008.fasc  &  get.string(33)  &  tffas008.depc 	 |# 209317.n   
 	  	  	 if tffas008.rpoa  =  tcyesno.yes then 	  	 |# 209446.sn   
 	  	  	  	 var.tffam110.salv  =  tffas007.pval*  (tffas008.remp  /  100)   
 	  	  	 else   
 	  	  	  	 var.tffam110.salv  =  tffas008.rema   
 	  	  	 endif 	  	  	  	  	  	 |# 209446.en   
 	  	  	 if tffas008.codp  =  tcyesno.yes then 	  	 |# 221360.sn   
 	  	  	  	 var.tffam110.ecre  =  1   
 	  	  	 endif 	  	  	  	  	  	 |# 221360.en   
 	  	 selectempty   
 | 	  	  	 select tffas005.ngrp,tffas005.depc 	  	 |# 209446.o   
 	  	  	 select tffas005.ngrp, tffas005.depc, tffas005.rema, |# 209446.sn   
 | 	  	  	  	 tffas005.rpoa, tffas005.remp 	  	 |# 209446.en |# 221360.o   
 	  	  	  	 tffas005.rpoa, tffas005.remp, tffas005.codp 	 |# 221360.n   
 	  	  	 from tffas005   
 	  	  	 where tffas005.ngrp  =  :tffas007.ngrp and tffas005.depc  =  :tffas002.depc   
 	  	  	 as set with 1 rows   
 	  	  	 selectdo   
 	  	  	  	 var.tffam110.book  =  tffas005.depc   
 	  	  	  	  	  	  	  	 |# 222897.sn   
 	  	  	  	 if var.tffam110.book  <>  tffas001.fdpc then   
 	  	  	  	  	 var.tffam110.post  =  2   
 	  	  	  	 else   
 	  	  	  	  	 var.tffam110.post  =  1   
 	  	  	  	 endif 	  	  	  	 |# 222897.en   
 	  	  	  	 var.tffam110.meth  =  get.string(34)  &  tffas005.ngrp  &  get.string(33)  &  tffas005.depc   
 	  	  	  	 if tffas005.rpoa  =  tcyesno.yes then 	 |# 209446.sn   
 	  	  	  	  	 var.tffam110.salv  =  tffas007.pval*  (tffas005.remp  /  100)   
 	  	  	  	 else   
 	  	  	  	  	 var.tffam110.salv  =  tffas005.rema   
 	  	  	  	 endif 	  	  	  	  	 |# 209446.en   
 	  	  	  	 if tffas005.codp  =  tcyesno.yes then 	  	 |# 221360.sn   
 	  	  	  	  	 var.tffam110.ecre  =  1   
 	  	  	  	 endif 	  	  	  	  	  	 |# 221360.en   
 	  	  	 selectempty   
 	  	  	  	 var.tffam110.book  =  tffas002.depc   
 	  	  	  	  	  	  	  	 |# 222897.sn   
 	  	  	  	 if var.tffam110.book  <>  tffas001.fdpc then   
 	  	  	  	  	 var.tffam110.post  =  2   
 	  	  	  	 else   
 	  	  	  	  	 var.tffam110.post  =  1   
 	  	  	  	 endif 	  	  	  	 |# 222897.en   
 	  	  	  	 var.tffam110.meth  =  get.string(33)  &  tffas002.depc   
 	  	  	  	 if tffas002.rpoa  =  tcyesno.yes then 	 |# 209446.sn   
 	  	  	  	  	 var.tffam110.salv  =  tffas007.pval*  (tffas002.remp  /  100)   
 	  	  	  	 else   
 	  	  	  	  	 var.tffam110.salv  =  tffas002.rema   
 	  	  	  	 endif 	  	  	  	  	 |# 209446.en   
 	  	  	  	 if tffas002.codp  =  tcyesno.yes then 	  	 |# 221360.sn   
 	  	  	  	  	 var.tffam110.ecre  =  1   
 	  	  	  	 endif 	  	  	  	  	  	 |# 221360.en   
 	  	  	 endselect   
 	  	 endselect   
 	  	  	 var.tffam110.last  =  0   
 	  	  	 select 	 tffas200.fasc, tffas200.depc, tffas200.year, tffas200.peri   
 	  	  	 from 	 tffas200   
 	  	  	 where 	 tffas200.fasc  =  :tffas007.fasc and tffas200.depc  =  :var.tffam110.book   
 	  	  	 order by tffas200.fasc, tffas200.depc, tffas200.year desc, tffas200.peri desc   
 	  	  	 as set with 1 rows   
 	  	  	 selectdo   
 	  	  	  	 var.year  =  tffas200.year   
 	  	  	  	 var.peri  =  tffas200.peri   
 	  	  	  	 var.peri  =  var.peri  +  1   
 	  	  	  	 select tfgld005.stdt   
 	  	  	  	 from tfgld005   
 	  	  	  	 where tfgld005._index1  =  {1, :var.year, :var.peri}   
 	  	  	  	 and tfgld005.corr  =  tcyesno.no |# 227900.n   
 	  	  	  	 as set with 1 rows   
 	  	  	  	 selectdo   
 	  	  	  	  	 var.tffam110.last  =  tfgld005.stdt  -  1   
 	  	  	  	 selectempty   
 	  	  	  	  	 select tfgld006.fpdt   
 	  	  	  	  	 from tfgld006   
 	  	  	  	  	 where tfgld006.year  =  :var.year   
 	  	  	  	  	 as set with 1 rows   
 	  	  	  	  	 selectdo   
 	  	  	  	  	  	 var.tffam110.last  =  tfgld006.fpdt   
 	  	  	  	  	 endselect   
 	  	  	  	 endselect   
 	  	  	 selectempty   
 	  	  	  	 select tffas201.fasc, tffas201.depc, tffas201.year   
 	  	  	  	 from tffas201   
 	  	  	  	 where tffas201.fasc  =  :tffas007.fasc and tffas201.depc  =  :var.tffam110.book   
 	  	  	  	 order by tffas201._index1 desc   
 	  	  	  	 as set with 1 rows   
 	  	  	  	 selectdo   
 	  	  	  	  	 var.year  =  tffas201.year   
 	  	  	  	  	 select tfgld006.fpdt   
 	  	  	  	  	 from tfgld006   
 	  	  	  	  	 where tfgld006.year  =  :var.year   
 	  	  	  	  	 as set with 1 rows   
 	  	  	  	  	 selectdo   
 	  	  	  	  	  	 var.tffam110.last  =  tfgld006.fpdt   
 	  	  	  	  	 endselect   
 	  	  	  	 endselect   
 	  	  	 endselect   
 	  	  	 var.tffam110.ltdd  =  0   
 	  	  	 var.tffam110.ytdd  =  0   
 	  	  	 select sum (tffas200.read):sum.read, sum (tffas200.vred):sum.vred, sum (tffas200.depr):sum.depr, sum (tffas200.rdep):sum.rdep, sum (tffas200.sdep):sum.sdep, sum (tffas200.sdre):sum.sdre, sum (tffas200.dead):sum.dead, tffas200.year   
 	  	  	 from tffas200   
 	  	  	 where tffas200.fasc  =  :tffas007.fasc and tffas200.depc  =  :var.tffam110.book   
 	  	  	 group by tffas200.year   
 	  	  	 selectdo   
 | 	  	  	  	 var.tffam110.ltdd  =  var.tffam110.ltdd  +  (sum.read  +  sum.vred  +  sum.depr  +  sum.rdep  +  sum.sdep  +  sum.sdre  -  sum.dead) 	 |# 225457.o   
 	  	  	  	 var.tffam110.ltdd  =  var.tffam110.ltdd  +  (sum.read  +  sum.vred  +  sum.depr  +  sum.rdep  +  sum.sdep  +  sum.sdre  +  sum.dead) 	 |# 225457.n   
 	  	  	  	 if tffas200.year  =  var.year then   
 | 	  	  	  	  	 var.tffam110.ytdd  =  sum.read  +  sum.vred  +  sum.depr  +  sum.rdep  +  sum.sdep  +  sum.sdre  -  sum.dead 	 |# 225457.o   
 	  	  	  	  	 var.tffam110.ytdd  =  sum.read  +  sum.vred  +  sum.depr  +  sum.rdep  +  sum.sdep  +  sum.sdre  +  sum.dead 	 |# 225457.n   
 	  	  	  	 endif   
 	  	  	 endselect   
 | 	  	  	 if var.tffam110.ltdd  =  0 then 	  	  	 |# 200  -  98001.so   
 | 	  	  	  	 var.tffam110.stat  =  2   
 | 	  	  	 else   
 | 	  	  	  	 var.tffam110.stat  =  3   
 | 	  	  	 endif 	  	  	  	  	  	 |# 200  -  98001.eo   
 	  	  	  	  	  	  	  	  	 |# 200  -  98001.sn   
 	  	  	 if var.tffam110.ltdd  <>  0 then   
 	  	  	  	  	  	  	  	 |# 222953.sn   
 	  	  	  	 if (tffas007.pval  -  var.tffam110.salv)  =  var.tffam110.ltdd then   
 	  	  	  	  	 var.tffam110.stat  =  5   
 	  	  	  	 else 	  	  	  	  	  	 |# 222953.en   
 	  	  	  	  	 var.tffam110.stat  =  3   
 	  	  	  	 endif 	  	  	  	 |# 222953.n   
 	  	  	 else   
 	  	  	  	 select tffas020.fasc,   
 	  	  	  	  	 tffas020.type   
 	  	  	  	 from 	 tffas020   
 	  	  	  	 where 	 tffas020.fasc  =  :tffas007.fasc   
 	  	  	  	 and 	 tffas020.depc  =  :var.tffam110.book 	 |#800  -  228521.n   
 	  	  	  	 and 	 tffas020.type  =  tffas.type.investment   
 	  	  	  	 as set with 1 rows   
 	  	  	  	 selectdo   
 	  	  	  	  	 select tffas101.fasc   
 	  	  	  	  	 from 	 tffas101   
 	  	  	  	  	 where 	 tffas101._index2  =  {:tffas007.fasc}   
 	  	  	  	  	 as set with 1 rows   
 	  	  	  	  	 selectdo   
 	  	  	  	  	  	 var.tffam110.stat  =  4   
 	  	  	  	  	 selectempty   
 	  	  	  	  	  	 var.tffam110.stat  =  2   
 	  	  	  	  	 endselect   
 	  	  	  	 selectempty   
 	  	  	  	  	 select tffas020.fasc, tffas020.type 	 |#800  -  228521.sn   
 	  	  	  	  	 from 	 tffas020   
 	  	  	  	  	 where 	 tffas020.fasc  =  :tffas007.fasc   
 	  	  	  	  	 and 	 tffas020.depc  <>  :var.tffam110.book   
 	  	  	  	  	 and 	 tffas020.type  =  tffas.type.investment   
 	  	  	  	  	 as set with 1 rows   
 	  	  	  	  	 selectdo   
 	  	  	  	  	  	 var.tffam110.stat  =  0   
 	  	  	  	  	  	 |********************************************     
 	  	  	  	  	  	 |*  There is an acquisition transaction for   
 	  	  	  	  	  	 |*  another book, but not for the current book.   
 	  	  	  	  	  	 |*  Skip this book, because a capitalized asset   
 	  	  	  	  	  	 |*  with asset books with status entered are   
 	  	  	  	  	  	 |*  not allowed in LN.   
 	  	  	  	  	  	 |********************************************     
 	  	  	  	  	 selectempty 	  	  	  	 |#800  -  228521.en   
 	  	  	  	  	  	 var.tffam110.stat  =  1   
 	  	  	  	  	 endselect 	  	  	  	 |#800  -  228521.n   
 	  	  	  	 endselect   
 	  	  	 endif   
 	  	  	 if var.tffam110.stat  =  0 then 	  	  	  	 |#800  -  228521.sn   
 	  	  	  	 continue   
 	  	  	 endif 	  	  	  	  	  	  	 |#800  -  228521.en   
 	  	  	  	  	  	  	  	 |# 225457.so   
 | 	  	  	  	  	  	  	  	 |# 223283.sn   
 | 	  	  	  	 if check.record.existin.tffas101.tffas103() then   
 | 	  	  	  	  	 var.tffam110.stat  =  4   
 | 	  	  	  	 endif 	  	  	  	 |# 223283.en   
 	  	  	  	  	  	  	  	 |# 225457.eo   
 	  	  	  	  	  	  	  	 |# 222953.sn   
 | 	  	  	  	 select 	 tccom000.ccur 	  	 |# 1061536.so   
 | 	  	  	  	 from 	 tccom000   
 | 	  	  	  	 where 	 tccom000._compnr  =  :i.comp   
 | 	  	  	  	 as set with 1 rows   
 | 	  	  	  	 selectdo   
 | 	  	  	  	  	 tolerance  =  bcint.dll1402.get.tolerance(   
 | 	  	  	  	  	  	 tccom000.ccur)   
 | 	  	  	  	 endselect 	  	  	 |# 1061536.eo   
 	  	  	  	  	  	  	  	 |# 1061536.sn   
 	  	  	  	 g.currency  =  get.home.currency.orig.comp()   
 	  	  	  	 tolerance  =  bcint.dll1402.get.tolerance(   
 	  	  	  	  	 g.currency) 	  	 |# 1061536.en   
 	  	  	 if double.cmp(tffas007.pval, 0.0, tolerance)  =  1 then   
 	  	  	  	 if not double.cmp((tffas007.pval  -  var.tffam110.ltdd  -     
 	  	  	 var.tffam110.salv), 0.0, tolerance)  =  1 then   
 	  	  	  	  	 var.tffam110.stat  =  5   
 	  	  	  	 endif   
 	  	  	 else   
 	  	  	  	 if not double.cmp((tffas007.pval  -  var.tffam110.ltdd  -     
 	  	  	 var.tffam110.salv), 0.0, tolerance)  =    -  1 then   
 	  	  	  	  	 if tffas007.pval  <>  0 and var.tffam110.ltdd  <>  0 then |# 227065.n   
 	  	  	  	  	 var.tffam110.stat  =  5   
 	  	  	  	  	 endif 	  	  	 |# 227065.n   
 	  	  	  	 endif   
 	  	  	 endif   
 	  	  	  	  	  	  	  	 |# 222953.en   
 	  	  	  	  	  	  	  	 |# 225457.sn   
 	  	  	 if check.record.existin.tffas101.tffas103() then   
 	  	  	  	 var.tffam110.stat  =  4   
 	  	  	 endif 	  	  	  	  	 |# 225457.en   
 	  	  	  	  	  	  	  	 |# 200  -  100980.sn   
 	  	  	 var.tffam110.life  =  0   
 	  	  	 end.year  =  0   
 	  	  	 end.prod  =  0   
 	  	  	 end.day  =  0   
 	  	  	 start.year  =  0   
 	  	  	 start.prod  =  0   
 	  	  	 start.day  =  0   
 | 	  	  	 if tffas007.nuse  <>  0 then 	  	 |# 242670.so   
 | 	  	  	  	 var.tffam110.life  =  tffas007.nuse*  12   
 | 	  	  	 else 	  	  	  	  	 |# 242670.eo   
 | 	  	  	  	 ret  =  string.scan(str$(tffas007.ltdt),"%d-%d-%d",end.day,end.prod,end.year) |# 227900.so   
 | 	  	  	  	 ret  =  string.scan(str$(tffas007.fudt),"%d-%d-%d",start.day,start.prod,start.year) |# 227900.eo   
 	  	  	  	 ret  =  num.to.date(tffas007.ltdt,end.year,end.prod,end.day) |# 227900.sn   
 	  	  	  	 ret  =  num.to.date(tffas007.fudt,start.year,start.prod,start.day) |# 227900.en   
 	  	  	  	 if end.year  =  start.year and   
 	  	  	  	 end.prod  =  start.prod and   
 	  	  	  	 end.day  =  start.day 	 then   
 	  	  	  	  	 continue   
 	  	  	  	 endif   
 	  	  	  	 if end.year  >  start.year then   
 	  	  	  	  	 if end.prod  >=  start.prod then   
 	  	  	  	  	  	 if end.day  >=  start.day then   
 	  	  	  	  	  	  	 var.tffam110.life  =  (end.year  -  start.year)*  12  +     
 	  	  	  	  	  	  	  	  	 end.prod  -  start.prod  +  1   
 	  	  	  	  	  	 else   
 	  	  	  	  	  	  	 var.tffam110.life  =  (end.year  -  start.year)*  12  +     
 	  	  	  	  	  	  	  	  	 end.prod  -  start.prod   
 	  	  	  	  	  	 endif   
 	  	  	  	  	 else   
 	  	  	  	  	  	 if end.day  >=  start.day then   
 	  	  	  	  	  	  	 var.tffam110.life  =  (end.year  -  start.year)*  12  -     
 	  	  	  	  	  	  	 (start.prod  -  end.prod)  +  1   
 	  	  	  	  	  	 else   
 	  	  	  	  	  	  	 var.tffam110.life  =  (end.year  -  start.year)*  12  -     
 	  	  	  	  	  	  	 (start.prod  -  end.prod)   
 	  	  	  	  	  	 endif   
 	  	  	  	  	 endif   
 	  	  	  	 else   
 	  	  	  	  	 if end.prod  >=  start.prod then   
 	  	  	  	  	  	 if end.day  >=  start.day then   
 	  	  	  	  	  	  	 var.tffam110.life  =  end.prod  -  start.prod  +  1   
 	  	  	  	  	  	 else   
 	  	  	  	  	  	  	 var.tffam110.life  =  end.prod  -  start.prod   
 	  	  	  	  	  	 endif   
 	  	  	  	  	 endif   
 	  	  	  	 endif   
 | 	  	  	 endif 	  	  	  	 |# 242670.o   
 	  	  	 if var.tffam110.life  =  0 then   
 | 	  	  	  	 var.tffam110.life  =  1 	 |# 242670.o   
 	  	  	  	 var.tffam110.life  =  60 	 |# 242670.n   
 	  	  	 endif   
 	  	  	  	  	  	  	  	  	  	 |# 200  -  100980.en   
 	  	  	 cnt  =  0   
 	  	  	 select 	 count(*  ):cnt   
 	  	  	 from 	 tfgld005   
 	  	  	 where 	 tfgld005._index2 between {1, :tffas007.fudt}   
 	  	  	  	  	 and 	 {1, :tffas007.ltdt}   
 	  	  	 and 	 tfgld005.stdt  <>  :tffas007.fudt   
 	  	  	 and 	 tfgld005.corr  =  tcyesno.no   
 	  	  	 and 	 tfgld005._compnr  =  :i.comp   
 	  	  	 selectdo   
 	  	  	 endselect   
 	  	  	 if cnt  =  0 then   
 	  	  	  	 cnt  =  1   
 	  	  	 endif 	  	  	  	  	 |# 200  -  98001.en   
 	  	  	  	  	  	  	  	 |# 224994.sn   
 	  	  	 if var.tffam110.ecre  =  1 then   
 	  	  	  	 temp.tffam110.ltdd  =  0   
 	  	  	  	 temp.tffam110.ytdd  =  0   
 	  	  	  	 first.time  =  false   
 	  	  	  	 select*     
 	  	  	  	 from tffas200   
 	  	  	  	 where tffas200.fasc  =  :tffas007.fasc and tffas200.depc  =  :var.tffam110.book and (tffas200.depr  =  0 and tffas200.dpco  <>  0)   
 	  	  	  	 order by tffas200.year,tffas200.peri   
 	  	  	  	 selectdo   
 	  	  	  	  	 if first.time  =  false then   
 	  	  	  	  	  	 first.time  =  true   
 	  	  	  	  	  	 temp.year  =  tffas200.year   
 	  	  	  	  	  	 temp.peri  =  tffas200.peri   
 	  	  	  	  	 endif   
 	  	  	  	  	 temp.tffam110.ltdd  =  temp.tffam110.ltdd  +  tffas200.dpco   
 	  	  	  	  	 if tffas200.year  =  var.year then   
 	  	  	  	  	  	 temp.tffam110.ytdd  =  temp.tffam110.ytdd  +  tffas200.dpco   
 	  	  	  	  	 endif   
 	  	  	  	 endselect   
 	  	  	  	 var.tffam110.ltdd  =  var.tffam110.ltdd  +  temp.tffam110.ltdd   
 	  	  	  	 var.tffam110.ytdd  =  var.tffam110.ytdd  +  temp.tffam110.ytdd   
 	  	  	 endif   
 	  	  	 if var.tffam110.book  =  tffas001.fdpc and var.tffam110.ecre  =  1 then   
 | 	  	  	  	 var.tffam110.book  =  "c9a"    	    |#   225935.o    
 	  	  	  	 var.tffam110.book  =  "C9A"    	    |#   225935.n    
 	  	  	  	 intialize.variable() 	  	 |# 225457.sn   
 	  	  	  	 read.transfered.asset() 	 |# 225457.en   
 	  	  	  	 dump 1   
 	  	  	  	 var.tffam110.book  =  tffas001.fdpc   
 	  	  	  	 var.tffam110.ecre  =  2   
 	  	  	  	 var.tffam110.ltdd  =  var.tffam110.ltdd  -  temp.tffam110.ltdd   
 	  	  	  	 if first.time then   
 	  	  	  	  	 if temp.peri  <>  1 and temp.year  =  var.year then   
 	  	  	  	  	  	 var.tffam110.ytdd  =  var.tffam110.ytdd  -  temp.tffam110.ytdd   
 	  	  	  	  	 else   
 	  	  	  	  	  	  	 flag  =  false   
 	  	  	  	  	  	 if temp.peri  =  1 then   
 	  	  	  	  	  	  	 temp.peri  =  12   
 	  	  	  	  	  	  	 temp.year  =  temp.year  -  1   
 	  	  	  	  	  	  	 flag  =  true   
 	  	  	  	  	  	 endif   
 	  	  	  	  	  	 select sum (tffas200.read):sum.read, sum (tffas200.vred):sum.vred, sum (tffas200.depr):sum.depr, sum (tffas200.rdep):sum.rdep, sum (tffas200.sdep):sum.sdep, sum (tffas200.sdre):sum.sdre, sum (tffas200.dead):sum.dead, tffas200.year   
 	  	  	  	  	  	 from tffas200   
 	  	  	  	  	  	 where tffas200.fasc  =  :tffas007.fasc and tffas200.depc  =  :var.tffam110.book and tffas200.year  =  :temp.year   
 	  	  	  	  	  	 group by tffas200.year   
 	  	  	  	  	  	 selectdo   
 | 	  	  	  	  	  	  	 var.tffam110.ytdd  =  sum.read  +  sum.vred  +  sum.depr  +  sum.rdep  +  sum.sdep  +  sum.sdre  -  sum.dead |# 225457.0   
 	  	  	  	  	  	  	 var.tffam110.ytdd  =  sum.read  +  sum.vred  +  sum.depr  +  sum.rdep  +  sum.sdep  +  sum.sdre  +  sum.dead |# 225457.n   
 	  	  	  	  	  	 endselect   
 	  	  	  	  	 endif   
 	  	  	  	  	 if flag then   
 	  	  	  	  	  	 temp.year  =  temp.year  +  1   
 	  	  	  	  	  	 temp.peri  =  1   
 	  	  	  	  	 endif   
 	  	  	  	  	 select tfgld005.stdt   
 	  	  	  	  	 from tfgld005   
 	  	  	  	  	 where tfgld005._index1  =  {1, :temp.year, :temp.peri}   
 	  	  	  	  	 as set with 1 rows   
 	  	  	  	  	 selectdo   
 	  	  	  	  	  	 var.tffam110.last  =  tfgld005.stdt  -  1   
 	  	  	  	  	 selectempty   
 	  	  	  	  	  	 select tfgld006.fpdt   
 	  	  	  	  	  	 from tfgld006   
 	  	  	  	  	  	 where tfgld006.year  =  :temp.year   
 	  	  	  	  	  	 as set with 1 rows   
 	  	  	  	  	  	 selectdo   
 	  	  	  	  	  	  	 var.tffam110.last  =  tfgld006.fpdt   
 	  	  	  	  	  	 endselect   
 	  	  	  	  	 endselect   
 	  	  	  	 endif   
 	  	  	 endif 	  	  	  	  	 |# 224994.en   
 	  	  	 intialize.variable() 	  	 |# 225457.sn   
 	  	  	 read.transfered.asset() 	  	 |# 225457.en   
 	  	  	 dump 1   
 	  	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:110
:SCPAC:tf
:SCMOD:fas
:SFLNO:007
:ICOD:S
:QURY:START
select tffas007.*     
from tffas007   
 |where NOT EXISTS (select tffas101.fasc from tffas101   
 |where tffas101.fasc  =  tffas007.fasc)   
 	  	  	  	  	  	  	  	 |# 200  -  98001.o
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:110
:SCPAC:tf
:SCMOD:fas
:SFLNO:007
:ICOD:X
:QURY:START
endselect
:QURY:END
:TEXT:

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

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

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:765
:SCPAC:tf
:SCMOD:fas
:SFLNO:009
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:765
:SCPAC:tf
:SCMOD:fas
:SFLNO:009
:ICOD:S
:QURY:START
select tffas009.*   
from tffas009
where tffas009.varp  <>  0 and  	  NOT EXISTS (select tffas101.fasc   
 	   	   	   	  from tffas101   
 	   	   	   	  where tffas101.fasc  =  tffas009.fasc)
:QURY:END
:TEXT:
Only those records in %STtffas009 are migrated to %TTtffam765 for which the fixed asset is not disposed and for
which the %STtffas009.varp < > 0
:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:765
:SCPAC:tf
:SCMOD:fas
:SFLNO:009
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:800
:SCPAC:tf
:SCMOD:fas
:SFLNO:020
:ICOD:D
:QURY:START
ldg.acct  =  ""    
 	  if tffas020.post  =  tcyesno.yes   
 	   	  and (tffas020.ttyp  =  "" or tffas020.docu  =   0) then    
 	   	  tffas020.post  =  tcyesno.no   
 	  endif   
 	  if (prev.fasc  <>  tffas020.fasc) then   
 |  	   	  get.lkey()  	   	   	   	   	  |# 1050599.o   
 	   	  invest  =  true   
 	   	  select tffas007.*     
 	   	  from  	  tffas007   
 	   	  where tffas007._index1  =  {:tffas020.fasc}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	   	   	   	   	   	   	  |# 1050599.sn   
 	   	   	  var.tffam120.lkey  =  bcint.dll0000.get.location.key(   
 	   	   	   	   	   	  tffas007.loca,   
 	   	   	   	   	   	  tffas007.fasc,   
 	   	   	   	   	   	  o.errmess,   
 	   	   	   	   	   	  true)   
 	   	   	  var.tffam120.dkey  =  bcint.dll0000.get.distribution.key(   
 	   	   	   	   	   	  tffas007.loca,   
 	   	   	   	   	   	  tffas007.fasc,   
 	   	   	   	   	   	  o.errmess,   
 	   	   	   	   	   	  true)  	   	  |# 1050599.en   
 |  	   	   	  i  =  1  	   	   	   	  |# 1050599.so   
 |  	   	   	  if isspace ( tffas007.loca ) then   
 |  	   	   	   	  var.tffam120.lkey  =  var.tffam050.sqvl   
 |  	   	   	  else   
 |  	   	   	   	  get.valueof.i()   
 |  	   	   	   	  var.tffam120.lkey  =  lkey ( i )   
 |  	   	   	  endif  	   	   	   	  |# 1050599.eo   
 	   	  endselect   
 	   	  prev.fasc  =  tffas020.fasc   
 	   	  inv.count  =  0   
 	   	  max.inv  =  0   
 	   	  addpost  =  false   
 	   	  if tffas001.fdpc  =  tffas020.depc then   
 	   	   	  check.addpost()   
 	   	  endif   
 	  endif   
 	  transaction.key  =  transaction.key  +  1   
 	  if (tffas020.type  =  tffas.type.investment) then   
 	   	  select  	  tffas004.mgrp   
 	   	  from  	  tffas004   
 	   	  where tffas004._index1  =  {:tffas007.ngrp}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  if prev.idpc  <>  tffas020.depc or invest  =  true then   
 	   	   	  prev.idpc  =  tffas020.depc   
 	   	   	  first.invst  =  0   
 	   	   	  invest  =  false   
 	   	  endif   
 	   	  if first.invst  =  0 then   
 	   	   	  first.invst  =  1   
 	   	  var.tffam800.atty  =  1   
 	   	  prev.inv.year  =  0   
 	   	  prev.inv.peri  =  0   
 	   	  dump.800()   
 	   	  check.depr.exist()   
 	   	  dump.810()   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  temp.depc  =  tffas020.depc   
 	   	   	  tffas020.depc  =  "C9A"    
 	   	   	  dump.800()   
 	   	   	  dump.810()   
 	   	   	  tffas020.depc  =  temp.depc   
 	   	  endif   
 	   	  if isspace(tffas020.lacd) then   
 	   	   	  get.accounts()   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacd   
 	   	   	  dim1  =  tffas020.did1   
 	   	   	  dim2  =  tffas020.did2   
 	   	   	  dim3  =  tffas020.did3   
 	   	   	  dim4  =  tffas020.did4   
 	   	   	  dim5  =  tffas020.did5   
 	   	  endif   
 	   	  dbcr.type  =  1   
 	   	  dump.815() | insert.record.in.tffam815(1,"debit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.815()   
 	   	  endif   
 	   	  if isspace(tffas020.lacc) then   
 	   	   	  fetch.record.from.tfgld106(tfgld.dbcr.credit)   
 	   	   	  if skip.record  =  true then   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	  endif   
 	   	   	   	  continue   
 	   	   	  endif   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacc   
 	   	   	  dim1  =  tffas020.dic1   
 	   	   	  dim2  =  tffas020.dic2   
 	   	   	  dim3  =  tffas020.dic3   
 	   	   	  dim4  =  tffas020.dic4   
 	   	   	  dim5  =  tffas020.dic5   
 	   	  endif   
 	   	  dbcr.type  =  2   
 	   	  dump.815() | insert.record.in.tffam815(1,"credit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  dump.815()   
 	   	  endif   
 	   	  else   
 	   	   	  check.depr.exist()   
 	   	   	  create.adj.trans()   
 	   	   	  first.invst  =  first.invst  +  1   
 	   	  endif   
 	  endif   
 	  if (tffas020.type  =  tffas.type.disposal) then   
 	   	  accum.depr  =  0   
 	   	  if (tffas020.batc  <>  0) then   
 	   	   	  if tffas007.quan  =  0 then   
 	   	   	  tffas007.quan  =  1   
 	   	   	  endif   
 	   	   	  var.tffam800.atty  =  18   
 	   	   	  get.book.value()   
 	   	   	  tffas020.amnt  =  temp.020amnt  -  var.bookvalue   
 	   	   	  dump.800() | insert.record.in.tffam800(4)   
 	   	   	  if addpost then   
 	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	  temp.depc  =  tffas020.depc   
 	   	   	   	  tffas020.depc  =  "C9A"    
 	   	   	   	  dump.800()   
 	   	   	   	  tffas020.depc  =  temp.depc   
 	   	   	  endif   
 	   	   	  tffas020.amnt  =  temp.020amnt   
 	   	   	  select tffas101.*     
 	   	   	  from  	  tffas101   
 	   	   	  where  	  tffas101._index2  =  {:tffas020.fasc}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	   	  select  	  sum(tffas200.depr):accum.depr   
 	   	   	  from  	  tffas200   
 	   	   	  where  	  tffas200.fasc  =  :tffas020.fasc   
 	   	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	   	  and  	  ((tffas200.year  <  :tffas020.year)   
 	   	   	  or  	  (tffas200.year  =  :tffas020.year   
 	   	   	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	   	  select  	  sum(tffas200.depr):ytd.depr   
 	   	   	  from  	  tffas200   
 	   	   	  where  	  tffas200.fasc  =  :tffas020.fasc   
 	   	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	   	  and  	  tffas200.year  =  :tffas020.year   
 	   	   	  and  	  tffas200.peri  <=  :tffas020.peri   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	   	  dump.840() | insert.record.in.tffam840(4)   
 	   	   	  if addpost then   
 	   	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	   	  dump.840()   
 	   	   	  endif   
 	   	   	  get.craccounts()   
 	   	   	  var.tffam845.amnt  =  (  -  1)  *  (accum.depr)   
 	   	   	  dbcr.type  =  2   
 	   	   	  dump.845() | insert.record.in.tffam845(4,"credit")   
 	   	   	  if addpost then   
 	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	  dump.845()   
 	   	   	  endif   
 	   	   	  tffas020.type  =  tffas.type.investment   
 	   	   	  get.accounts()   
 	   	   	  var.tffam845.amnt  =  (  -  1)  *  (tffas007.pval)   
 	   	   	  dbcr.type  =  1   
 	   	   	  dump.845() | insert.record.in.tffam845(4,"debit")   
 	   	   	  if addpost then   
 	   	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	   	  dump.845()   
 	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  endif   
 	   	  endif   
 	  endif   
 	  if (tffas020.type  =  tffas.type.depreciation) then   
 	   	  accum.depr  =  0   
 	   	  ytd.depr  =  0   
 	   	  accum.depr3  =  0   
 	   	  ytd.depr3  =  0   
 	   	  select  	  sum(tffas200.depr):accum.depr   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  ((tffas200.year  <  :tffas020.year)   
 	   	  or  	  (tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  select sum(tffas200.dead):accum.depr3   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  ((tffas200.year  <  :tffas020.year)   
 	   	  or  	  (tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  accum.depr  =  accum.depr  +  accum.depr3   
 	   	  select sum(tffas200.depr):ytd.depr   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  select sum(tffas200.dead):ytd.depr3   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <  :tffas020.peri   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  ytd.depr  =  ytd.depr  +  ytd.depr3   
 	   	  var.tffam800.atty  =  3   
 	   	  dump.800() | insert.record.in.tffam800(3)   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  temp.depc  =  tffas020.depc   
 	   	   	  tffas020.depc  =  "C9A"    
 	   	   	  dump.800()   
 	   	   	  tffas020.depc  =  temp.depc   
 	   	  endif   
 	   	  if (tffas020.peri  <  12) then   
 	   	   	  select  	  tfgld005.stdt   
 	   	   	  from  	  tfgld005   
 	   	   	  where  	  tfgld005._index1  =  {1,:tffas020.year,:tffas020.peri  +  1}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  else   
 	   	   	  select  	  tfgld005.stdt   
 	   	   	  from  	  tfgld005   
 	   	   	  where  	  tfgld005._index1  =  {1,:tffas020.year  +  1}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  endif   
 	   	  recovery.date  =  utc(tfgld005.stdt  -  1,0,2)   
 	   	  get.deprcode()   
 	   	  dump.830() | insert.record.in.tffam830()   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.830()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  if isspace(tffas020.lacd) then   
 	   	   	  get.accounts()   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacd   
 	   	   	  dim1  =  tffas020.did1   
 	   	   	  dim2  =  tffas020.did2   
 	   	   	  dim3  =  tffas020.did3   
 	   	   	  dim4  =  tffas020.did4   
 	   	   	  dim5  =  tffas020.did5   
 	   	  endif   
 	   	  dbcr.type  =  1   
 	   	  dump.835() | insert.record.in.tffam835(1,"debit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.835()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  if isspace(tffas020.lacc) then   
 	   	   	  fetch.record.from.tfgld106(tfgld.dbcr.credit)   
 	   	   	  if skip.record  =  true then   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	  endif   
 	   	   	   	  continue   
 	   	   	  endif   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacc   
 	   	   	  dim1  =  tffas020.dic1   
 	   	   	  dim2  =  tffas020.dic2   
 	   	   	  dim3  =  tffas020.dic3   
 	   	   	  dim4  =  tffas020.dic4   
 	   	   	  dim5  =  tffas020.dic5   
 	   	  endif   
 	   	  dbcr.type  =  2   
 	   	  dump.835() | insert.record.in.tffam835(1,"credit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  dump.835()   
 	   	  endif   
 	   	  if (prev.depc  <>  tffas020.depc) or (prev.fasc1  <>  tffas020.fasc) or   
 	   	   	   	   	  (prev.type  <>  etol(tffas020.type)) then   
 	   	   	  prev.year  =  0   
 	   	   	  prev.peri  =  0   
 	   	   	  prev.depc  =  tffas020.depc   
 	   	   	  prev.fasc1  =  tffas020.fasc   
 	   	   	  prev.type  =  etol(tffas020.type)   
 	   	  endif   
 	   	   	  if prev.inv.year  <>  tffas020.year or  	  |# 242525.sn   
 	   	   	   	  prev.inv.peri  <>  tffas020.peri then   
 	   	   	   	   	   	   	   	  |# 242525.en   
 	   	   	  if (prev.year  <>  tffas020.year) or (prev.peri  <>  tffas020.peri)  	  then   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	   	  endif   
 	   	   	   	  get.tffam808.cost()   
 	   	   	   	  dump.808() | tffam808   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	   	  temp.depc  =  tffas020.depc   
 	   	   	   	   	  tffas020.depc  =  "C9A"    
 	   	   	   	   	  dump.808()   
 	   	   	   	   	  tffas020.depc  =  temp.depc   
 	   	   	   	  endif   
 	   	   	   	  prev.year  =  tffas020.year   
 	   	   	   	  prev.peri  =  tffas020.peri   
 	   	   	  endif   
 	   	   	  endif  	   	   	   	   	  |# 242525.n   
 	  endif   
 	  if (tffas020.type  =  tffas.type.depr.costs and addpost) or   
 	   	   	  (tffas020.type  =  tffas.type.depr.costs and tffas001.fdpc  <>  tffas020.depc) then   
 	  fas.year  =  tffas020.year   
 	  fas.peri  =  tffas020.peri   
 	  prev.depc_cost  =  tffas020.depc   
 	  prev.fasc_cost  =  tffas020.fasc   
 	  select  	  tffas020.depc, tffas020.fasc, tffas020.type, tffas020.year,   
 	   	   	  tffas020.peri, tffas020.ttim, tffas020.sern   
 	  from  	  tffas020   
 	  where  	  tffas020.depc  =  :prev.depc_cost   
 	  and  	  tffas020.fasc  =  :prev.fasc_cost   
 	  and  	  tffas020.type  =  tffas.type.depreciation   
 	  order by tffas020.depc, tffas020.fasc,tffas020.type, tffas020.year desc, tffas020.peri desc, tffas020.ttim desc, tffas020.sern desc   
 	  as set with 1 rows   
 	  selectdo   
 	   	  prev.year  =  tffas020.year   
 	   	  prev.peri  =  tffas020.peri   
 	  endselect   
 	  tffas020.year  =  fas.year   
 	  tffas020.peri  =  fas.peri   
 	  if (fas.year  =  prev.year and fas.peri  >  prev.peri) or (fas.year  >  prev.year) then   
 	   	  var.tffam800.atty  =  8   
 	  else   
 	   	  continue   
 	  endif   
 	  temp.depc  =  tffas020.depc   
 	  if tffas001.fdpc  =  tffas020.depc then   
 	   	  tffas020.depc  =  "C9A"    
 	  endif   
 	  accum.depr  =  0   
 	  ytd.depr  =  0   
 	  accum.depr3  =  0   
 	  ytd.depr3  =  0   
 	  select  	  sum(tffas200.dpco):accum.depr   
 	  from  	  tffas200   
 	  where tffas200.fasc  =  :tffas020.fasc   
 	  and  	  tffas200.depc  =  :tffas020.depc   
 	  and  	  ((tffas200.year  <  :tffas020.year)   
 	  or  	  (tffas200.year  =  :tffas020.year   
 	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	  select  	  sum(tffas200.dead):accum.depr3   
 	  from  	  tffas200   
 	  where tffas200.fasc  =  :tffas020.fasc   
 	  and  	  tffas200.depc  =  :tffas020.depc   
 	  and  	  ((tffas200.year  <  :tffas020.year)   
 	  or  	  (tffas200.year  =  :tffas020.year   
 	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	  accum.depr  =  accum.depr  +  accum.depr3   
 	  select sum(tffas200.dpco):ytd.depr   
 	  from  	  tffas200   
 	  where tffas200.fasc  =  :tffas020.fasc   
 	  and  	  tffas200.depc  =  :tffas020.depc   
 	  and  	  tffas200.year  =  :tffas020.year   
 	  and  	  tffas200.peri  <=  :tffas020.peri   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	  select sum(tffas200.dead):ytd.depr3   
 	  from  	  tffas200   
 	  where tffas200.fasc  =  :tffas020.fasc   
 	  and  	  tffas200.depc  =  :tffas020.depc   
 	  and  	  tffas200.year  =  :tffas020.year   
 	  and  	  tffas200.peri  <  :tffas020.peri   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 	  ytd.depr  =  ytd.depr  +  ytd.depr3   
 	  dump.800()   
 	  tffas020.depc  =  temp.depc   
 	  if (tffas020.peri  <  12) then   
 	   	   	  select tfgld005.stdt   
 	   	   	  from  	  tfgld005   
 	   	   	  where  	  tfgld005._index1  =  {1,:fas.year,:fas.peri  +  1}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	  else   
 	   	   	  select tfgld005.stdt   
 	   	   	  from  	  tfgld005   
 	   	   	  where  	  tfgld005._index1  =  {1,:fas.year  +  1}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	  endif   
 	   	  recovery.date  =  utc(tfgld005.stdt  -  1,0,2)   
 	   	  get.deprcode()   
 	   	  dump.830()   
 	   	  if isspace(tffas020.lacd) then   
 	   	   	  get.accounts()   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacd   
 	   	   	  dim1  =  tffas020.did1   
 	   	   	  dim2  =  tffas020.did2   
 	   	   	  dim3  =  tffas020.did3   
 	   	   	  dim4  =  tffas020.did4   
 	   	   	  dim5  =  tffas020.did5   
 	   	  endif   
 	   	  dbcr.type  =  1   
 	   	  dump.835() | insert.record.in.tffam835(1,"debit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.835()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  if isspace(tffas020.lacc) then   
 	   	   	  fetch.record.from.tfgld106(tfgld.dbcr.credit)   
 	   	   	  if skip.record  =  true then   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	  endif   
 	   	   	   	  continue   
 	   	   	  endif   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacc   
 	   	   	  dim1  =  tffas020.dic1   
 	   	   	  dim2  =  tffas020.dic2   
 	   	   	  dim3  =  tffas020.dic3   
 	   	   	  dim4  =  tffas020.dic4   
 	   	   	  dim5  =  tffas020.dic5   
 	   	  endif   
 	   	  dbcr.type  =  2   
 	   	  dump.835() | insert.record.in.tffam835(1,"credit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  dump.835()   
 	   	  endif   
 	   	  if (prev.depc_cost  <>  tffas020.depc) or (prev.fasc_cost  <>  tffas020.fasc) or   
 	   	   	   	   	  (prev.type  <>  etol(tffas020.type)) then   
 	   	   	  prev.year  =  0   
 	   	   	  prev.peri  =  0   
 	   	   	  prev.depc  =  tffas020.depc   
 	   	   	  prev.fasc1  =  tffas020.fasc   
 	   	   	  prev.type  =  etol(tffas020.type)   
 	   	  endif   
 	   	   	  if (tffas020.year  =  prev.year and tffas020.peri  >  prev.peri) or (tffas020.year  >  prev.year) then   
 	   	   	   	  temp.depc  =  tffas020.fasc   
 	   	   	   	  if tffas001.fdpc  =  tffas020.depc then   
 	   	   	   	   	  tffas020.depc  =  "C9A"    
 	   	   	   	  endif   
 	   	   	   	  get.tffam808.cost()   
 	   	   	   	  dump.808() | tffam808   
 	   	   	   	  tffas020.depc  =  temp.depc   
 	   	   	  endif   
 	  endif   
 	  if (tffas020.type  =  tffas.type.revaluation) then   
 	   	  var.tffam800.atty  =  12   
 	   	  dump.800() | insert.record.in.tffam800(1)   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  temp.depc  =  tffas020.depc   
 	   	   	  tffas020.depc  =  "C9A"    
 	   	   	  dump.800()   
 	   	   	  tffas020.depc  =  temp.depc   
 	   	  endif   
 	  endif   
 	  if (tffas020.type  =  tffas.type.depr.rev) then   
 	   	  accum.depr  =  0   
 	   	  ytd.depr  =  0   
 	   	  accum.depr1  =  0   
 	   	  ytd.depr1  =  0   
 	   	  accum.depr2  =  0   
 	   	  ytd.depr2  =  0   
 	   	  accum.depr3  =  0   
 	   	  ytd.depr3  =  0   
 	   	  accum.depr4  =  0  	   	   	   	  |# 1061536.sn   
 	   	  ytd.depr4  =  0  	   	   	   	   	  |# 1061536.en   
 	   	  select sum(tffas200.depr):accum.depr1,   
 	   	   	  sum(tffas200.rdep):accum.depr2,   
 |  	   	   	  sum(tffas200.dead):accum.depr3  	  |# 1061536.o   
 	   	   	  sum(tffas200.dead):accum.depr3,  	  |# 1061536.sn   
 	   	   	  sum(tffas200.vred):accum.depr4  	  |# 1061536.en   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  ((tffas200.year  <  :tffas020.year)   
 	   	  or  	  (tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  accum.depr  =  accum.depr1  +  accum.depr2  +  accum.depr3   
 	   	    +  accum.depr4  	   	   	   	  |# 1061536.n   
 	   	  select sum(tffas200.depr):ytd.depr1,   
 	   	   	  sum(tffas200.rdep):ytd.depr2,   
 |  	   	   	  sum(tffas200.dead):ytd.depr3  	   	  |# 1061536.o   
 	   	   	  sum(tffas200.dead):ytd.depr3,  	   	  |# 1061536.sn   
 	   	   	  sum(tffas200.vred):ytd.depr4  	   	  |# 1061536.en   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	   	  ytd.depr  =  ytd.depr1  +  ytd.depr2  +  ytd.depr3   
 	   	    +  ytd.depr4  	   	   	   	   	  |# 1061536.n   
 	   	  var.tffam800.atty  =  3   
 	   	  dump.800() | insert.record.in.tffam800(3)   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  temp.depc  =  tffas020.depc   
 	   	   	  tffas020.depc  =  "C9A"    
 	   	   	  dump.800()   
 	   	   	  tffas020.depc  =  temp.depc   
 	   	  endif   
 	   	  if (tffas020.peri  <  12) then   
 	   	   	  select tfgld005.stdt   
 	   	   	  from  	  tfgld005   
 	   	   	  where  	  tfgld005._index1  =  {1,:tffas020.year,:tffas020.peri  +  1}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  else   
 	   	   	  select tfgld005.stdt   
 	   	   	  from  	  tfgld005   
 	   	   	  where  	  tfgld005._index1  =  {1,:tffas020.year  +  1}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  endif   
 	   	  recovery.date  =  utc(tfgld005.stdt  -  1,0,2)   
 	   	  get.deprcode()   
 	   	  dump.830() | insert.record.in.tffam830()   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.830()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  if isspace(tffas020.lacd) then   
 	   	   	  get.accounts()   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacd   
 	   	   	  dim1  =  tffas020.did1   
 	   	   	  dim2  =  tffas020.did2   
 	   	   	  dim3  =  tffas020.did3   
 	   	   	  dim4  =  tffas020.did4   
 	   	   	  dim5  =  tffas020.did5   
 	   	  endif   
 	   	  dbcr.type  =  1   
 	   	  dump.835() | insert.record.in.tffam835(1,"debit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.835()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  if isspace(tffas020.lacc) then   
 	   	   	  fetch.record.from.tfgld106(tfgld.dbcr.credit)   
 	   	   	  if skip.record  =  true then   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	  endif   
 	   	   	   	  continue   
 	   	   	  endif   
 	   	  else   
 	   	   	  ldg.acct  =  tffas020.lacc   
 	   	   	  dim1  =  tffas020.dic1   
 	   	   	  dim2  =  tffas020.dic2   
 	   	   	  dim3  =  tffas020.dic3   
 	   	   	  dim4  =  tffas020.dic4   
 	   	   	  dim5  =  tffas020.dic5   
 	   	  endif   
 	   	  dbcr.type  =  2   
 	   	  dump.835() | insert.record.in.tffam835(1,"credit")   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  dump.835()   
 	   	  endif   
 	   	  if (prev.depc  <>  tffas020.depc) or (prev.fasc1  <>  tffas020.fasc) or   
 	   	   	   	   	  (prev.type  <>  etol(tffas020.type)) then   
 	   	   	  prev.year  =  0   
 	   	   	  prev.peri  =  0   
 	   	   	  prev.depc  =  tffas020.depc   
 	   	   	  prev.fasc1  =  tffas020.fasc   
 	   	   	  prev.type  =  etol(tffas020.type)   
 	   	  endif   
 	  endif   
 	  if (tffas020.type  =  tffas.type.depr.adju) then   
 	   	  accum.depr  =  0   
 	   	  ytd.depr  =  0   
 	   	  accum.depr1  =  0   
 	   	  accum.depr2  =  0   
 	   	  accum.depr3  =  0   
 	   	  accum.depr4  =    	  0  	   	   	   	  |# 1061536.n   
 	   	  ytd.depr1  =  0   
 	   	  ytd.depr2  =  0   
 	   	  ytd.depr3  =  0   
 	   	  ytd.depr4  =  0  	   	   	   	   	  |# 1061536.n   
 	   	  var.tffam820.cosz  =  8   
 	   	  var.tffam820.cost  =  0   
 	   	  select sum(tffas200.depr):accum.depr1,   
 	   	   	  sum(tffas200.rdep):accum.depr2,   
 |  	   	   	  sum(tffas200.dead):accum.depr3  	  |# 1061536.o   
 	   	   	  sum(tffas200.dead):accum.depr3,  	  |# 1061536.sn   
 	   	   	  sum(tffas200.vred):accum.depr4  	  |# 1061536.en   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  ((tffas200.year  <  :tffas020.year)   
 	   	  or  	  (tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri))   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	  accum.depr  =  accum.depr1  +  accum.depr2  +  accum.depr3   
 	   	    +  accum.depr4  	   	   	   	  |# 1061536.n   
 	   	  select sum(tffas200.depr):ytd.depr1,   
 	   	   	  sum(tffas200.rdep):ytd.depr2,   
 |  	   	   	  sum(tffas200.dead):ytd.depr3  	   	  |# 1061536.o   
 	   	   	  sum(tffas200.dead):ytd.depr3,  	   	  |# 1061536.sn   
 	   	   	  sum(tffas200.vred):ytd.depr4  	   	  |# 1061536.en   
 	   	  from  	  tffas200   
 	   	  where tffas200.fasc  =  :tffas020.fasc   
 	   	  and  	  tffas200.depc  =  :tffas020.depc   
 	   	  and  	  tffas200.year  =  :tffas020.year   
 	   	  and  	  tffas200.peri  <=  :tffas020.peri   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	   	   	  ytd.depr  =  ytd.depr1  +  ytd.depr2  +  ytd.depr3   
 	   	   	    +  ytd.depr4  	   	   	   	  |# 1061536.n   
 	   	  var.tffam800.atty  =  2   
 	   	  dump.800() | insert.record.in.tffam800(3)   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	  temp.depc  =  tffas020.depc   
 	   	   	  tffas020.depc  =  "C9A"    
 	   	   	  dump.800()   
 	   	   	  tffas020.depc  =  temp.depc   
 	   	  endif   
 	   	  get.deprcode()   
 	   	  get.tffam808.cost()   
 	   	  var.tffam821.cost  =  var.tffam808.cost   
 	   	  var.tffam820.ltdd  =  tffas020.amnt   
 	   	  var.tffam820.ltdz  =  1   
 	   	  dump.820() | insert.record.in.tffam820()   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.820()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  var.tffam821.orig  =  1   
 	   	  var.tffam821.ltdd  =  accum.depr  -  tffas020.amnt   
 	   	  var.tffam821.ytdd  =  ytd.depr  -  tffas020.amnt   
 	   	  dump.821() | insert.record.in.tffam821() ORIGINAL VALUES   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.821()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	   	  var.tffam821.orig  =  2   
 	   	  var.tffam821.ltdd  =  accum.depr   
 	   	  var.tffam821.ytdd  =  ytd.depr   
 	   	  dump.821() | insert.record.in.tffam821() NEW VALUES   
 	   	  if addpost then   
 	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	  dump.821()   
 	   	   	  transaction.key  =  transaction.key  +  1   
 	   	  endif   
 	  endif   
 	  if (tffas020.type  =  tffas.type.transferred) then   
 	   	  transin  =  true   
 	   	  select tffas103.*     
 	   	  from  	  tffas103   
 	   	  where tffas103.ofas  =  :tffas020.fasc   
 	   	  selectdo   
 	   	   	  transin  =  false   
 	   	  selectempty   
 	   	   	  transin  =  true   
 	   	  endselect   
 	   	  if transin then   
 	   	   	  continue   
 	   	  endif   
 	   	   	  if inv.count  =  0 then   
 	   	   	   	  temp.type  =  tffas020.type   
 	   	   	   	  select tffas020.type,   
 	   	   	   	   	  tffas020.fasc,   
 	   	   	   	   	  tffas020.depc   
 	   	   	   	  from tffas020   
 	   	   	   	  where tffas020.type  =  tffas.type.investment   
 	   	   	   	  and tffas020.depc  =  :tffas020.depc   
 	   	   	   	  and tffas020.fasc  =  :tffas020.fasc   
 	   	   	   	  selectdo   
 	   	   	   	   	  inv.count  =  inv.count  +  1   
 	   	   	   	  endselect   
 	   	   	   	  tffas020.type  =  temp.type   
 	   	   	   	  max.inv  =  inv.count   
 	   	   	  endif   
 	   	   	  if tffas007.quan  =  0 then   
 	   	   	   	  tffas007.quan  =  1   
 	   	   	  endif   
 	   	   	  if inv.count  >  0 then   
 	   	   	   	  max.inv  =  max.inv  -  1   
 	   	   	   	  if max.inv  =  0 then   
 	   	   	   	  inv.count  =    -  1   
 	   	   	   	  tffas020.amnt  =  (  -  1)  *  (tffas007.pval)   
 	   	   	   	  var.tffam810.trid  =  transaction.key   
 	   	   	   	  var.tffam810.xanb  =  tffas103.fasc   
 	   	   	   	  var.tffam810.ltdd  =  (  -  1)  *  tffas103.depr   
 	   	   	   	  var.tffam800.atty  =  6   
 	   	   	   	  dump.800() | insert.record.in.tffam800(1)   
 	   	   	   	  dump.810() | insert.record.in.tffam810(1)   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	   	  temp.depc  =  tffas020.depc   
 	   	   	   	   	  tffas020.depc  =  "C9A"    
 	   	   	   	   	  dump.800()   
 	   	   	   	   	  dump.810()   
 	   	   	   	   	  tffas020.depc  =  temp.depc   
 	   	   	   	  endif   
 	   	   	   	  var.tffam810.trid  =  0   
 	   	   	   	  var.tffam810.xanb  =  tffas020.fasc   
 	   	   	   	  var.tffam810.ltdd  =  0   
 	   	   	   	  if tffas001.fdpc  =  tffas020.depc then   
 	   	   	   	   	  if isspace(tffas020.lacc) then   
 	   	   	   	   	   	  tffas020.type  =  tffas.type.investment   
 	   	   	   	   	   	  get.accounts()   
 	   	   	   	   	  else   
 	   	   	   	   	   	  ldg.acct  =  tffas020.lacc   
 	   	   	   	   	   	  dim1  =  tffas020.dic1   
 	   	   	   	   	   	  dim2  =  tffas020.dic2   
 	   	   	   	   	   	  dim3  =  tffas020.dic3   
 	   	   	   	   	   	  dim4  =  tffas020.dic4   
 	   	   	   	   	   	  dim5  =  tffas020.dic5   
 	   	   	   	   	  endif   
 	   	   	   	   	  dbcr.type  =  1   
 	   	   	   	   	  var.tffam815.trid  =  transaction.key   
 	   	   	   	   	  tffas020.amnt  =  (  -  1)  *  tffas007.pval   
 	   	   	   	   	  dump.815() | insert.record.in.tffam815(1,"debit")   
 	   	   	   	   	  if addpost then   
 	   	   	   	   	   	  transaction.key  =  transaction.key  -  1   
 	   	   	   	   	   	  dump.815()   
 	   	   	   	   	  endif   
 	   	   	   	   	   	  get.craccounts()   
 	   	   	   	   	  dbcr.type  =  2   
 	   	   	   	   	  tffas020.amnt  =  (  -  1)  *  tffas103.depr   
 	   	   	   	   	  dump.815() | insert.record.in.tffam815(1,"credit")   
 	   	   	   	   	  if addpost then   
 	   	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	   	   	  dump.815()   
 	   	   	   	   	  endif   
 	   	   	   	   	  var.tffam815.trid  =  0   
 	   	   	   	  endif   
 	   	   	   	  endif   
 	   	   	  else   
 	   	   	   	  if max.tra  =  999 then   
 	   	   	   	   	  tra.count  =  0   
 	   	   	   	   	  select tffas020.type,   
 	   	   	   	   	   	  tffas020.fasc,   
 	   	   	   	   	   	  tffas020.depc   
 	   	   	   	   	  from tffas020   
 	   	   	   	   	  where tffas020.type  =  tffas.type.transferred   
 	   	   	   	   	  and tffas020.depc  =  :tffas020.depc   
 	   	   	   	   	  and tffas020.fasc  =  :tffas020.fasc   
 	   	   	   	   	  selectdo   
 	   	   	   	   	   	  tra.count  =  tra.count  +  1   
 	   	   	   	   	  endselect   
 	   	   	   	   	   	  max.tra  =  tra.count  -  1   
 	   	   	   	  endif   
 	   	   	   	  if max.tra  <=  1 then   
 	   	   	   	  var.tffam800.atty  =  16   
 	   	   	   	  tffas020.amnt  =  (  -  1)  *  tffas020.amnt   
 	   	   	   	  dump.800() | insert.record.in.tffam800(1)   
 	   	   	   	  if addpost then   
 	   	   	   	   	  transaction.key  =  transaction.key  +  1   
 	   	   	   	   	  temp.depc  =  tffas020.depc   
 	   	   	   	   	  tffas020.depc  =  "C9A"    
 	   	   	   	   	  dump.800()   
 	   	   	   	   	  tffas020.depc  =  temp.depc   
 	   	   	   	  endif   
 	   	   	   	   	  max.tra  =  999   
 	   	   	   	  else   
 	   	   	   	   	  max.tra  =  max.tra  -  1   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:800
:SCPAC:tf
:SCMOD:fas
:SFLNO:020
:ICOD:S
:QURY:START
select  	  tffas020.*     
from 	  tffas020   
 | where  	  type in (1,2,3,6,7,8,9,12)  	   	   	   	  |# 1061536.o
where 	  type in (  	   	   	   	   	   	  |# 1061536.sn   
 	  tffas.type.investment,   
 	  tffas.type.disposal,   
 	  tffas.type.transferred,   
 	  tffas.type.depreciation,   
 	  tffas.type.depr.costs,   
 	  tffas.type.revaluation,   
 	  tffas.type.depr.rev,   
 	  tffas.type.depr.adju,   
 	  tffas.type.val.reductions)  	   	   	   	  |# 1061536.en
order by tffas020.depc,   
 	  tffas020.fasc,   
 	  tffas020.trdt, 	  	  	  	  	  	  |# 1900453.sn   
 	  tffas020.ttim, 	  	  	  	  	  	  |# 1900453.en   
 	  tffas020.type,   
 	  tffas020.year,   
 	  tffas020.peri
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fam
:TFLNO:800
:SCPAC:tf
:SCMOD:fas
:SFLNO:020
:ICOD:X
:QURY:START
| table tffas020
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:bc
:SCMOD:stf
:SFLNO:008
:ICOD:D
:QURY:START
	   	   	   	   	   	   	   	  |# FP10.sn   
 	  var.cvr.udim1  =  ""  	     
 	  var.cvr.udim2  =  ""   
 	  var.cvr.udim3  =  ""   
 	  var.cvr.udim4  =  ""   
 	  var.cvr.udim5  =  ""   
 	   	   	   	   	   	   	   	  |# FP10.en   
 	  var.tfgld008.atyp  =  get.account.type(bcstf008.leac)   
 	  if dimension1.used  =  tcyesno.yes then  	   	  |# 218049.sn   
 	   	  var.tfgld008.dim1  =  tfgld.dopt.optional   
 	   	  add.dimension.range.by.ledger.account(   
 |  	   	   	  bcstf008.leac,  	   	   	  |# 223223.o   
 	   	   	  bcstf008.cdca,  	   	   	   	  |# 223223.n   
 	   	   	  1,   
 	   	   	  var.cvr.udim1)  	   	   	  |# FP10.n   
 	  else  	   	   	     
 	   	  var.tfgld008.dim1  =  tfgld.dopt.no   
 	  endif  	   	   	   	     
 	  if dimension2.used  =  tcyesno.yes then   
 	   	  var.tfgld008.dim2  =  tfgld.dopt.optional   
 	   	  add.dimension.range.by.ledger.account(   
 |  	   	   	  bcstf008.leac,  	   	   	  |# 223223.o   
 	   	   	  bcstf008.cdca,  	   	   	   	  |# 223223.n   
 	   	   	  2,   
 	   	   	  var.cvr.udim2)  	   	   	  |# FP10.n   
 	  else  	   	   	     
 	   	  var.tfgld008.dim2  =  tfgld.dopt.no   
 	  endif  	     
 	  if dimension3.used  =  tcyesno.yes then   
 	   	  var.tfgld008.dim3  =  tfgld.dopt.optional   
 	   	  add.dimension.range.by.ledger.account(   
 |  	   	   	  bcstf008.leac,  	   	   	  |# 223223.o   
 	   	   	  bcstf008.cdca,  	   	   	   	  |# 223223.n   
 	   	   	  3,   
 	   	   	  var.cvr.udim3)  	   	   	  |# FP10.n   
 	  else  	   	   	     
 	   	  var.tfgld008.dim3  =  tfgld.dopt.no   
 	  endif   
 	  if dimension4.used  =  tcyesno.yes then   
 	   	  var.tfgld008.dim4  =  tfgld.dopt.optional   
 	   	  add.dimension.range.by.ledger.account(   
 |  	   	   	  bcstf008.leac,  	   	   	  |# 223223.o   
 	   	   	  bcstf008.cdca,  	   	   	   	  |# 223223.n   
 	   	   	  4,   
 	   	   	  var.cvr.udim4)  	   	   	  |# FP10.n   
 	  else  	   	   	     
 	   	  var.tfgld008.dim4  =  tfgld.dopt.no   
 	  endif   
 	  if dimension5.used  =  tcyesno.yes then   
 	   	  var.tfgld008.dim5  =  tfgld.dopt.optional   
 	   	  add.dimension.range.by.ledger.account(   
 |  	   	   	  bcstf008.leac,  	   	   	  |# 223223.o   
 	   	   	  bcstf008.cdca,  	   	   	   	  |# 223223.n   
 	   	   	  5,   
 	   	   	  var.cvr.udim5)  	   	   	  |# FP10.n   
 	  else  	   	   	     
 	   	  var.tfgld008.dim5  =  tfgld.dopt.no   
 	  endif  	   	   	   	   	   	  |# 218049.en   
 	   	   	   	   	   	   	   	   	  |# FP10.sn   
 	  dim.options(1)  =  var.tfgld008.dim1   
 	  dim.options(2)  =  var.tfgld008.dim2   
 	  dim.options(3)  =  var.tfgld008.dim3   
 	  dim.options(4)  =  var.tfgld008.dim4   
 	  dim.options(5)  =  var.tfgld008.dim5   
 	  nof.elements  =  0   
 	  set.mem(fdim.array, "")   
 	  set.mem(tdim.array, "")   
 	  convert.dimension.ranges.to.cvr.rule(   
 	   	  bcstf008.cdca,   
 	   	  dim.options,   
 	   	  array.depth,   
 	   	  nof.elements,   
 	   	  fdim.array,   
 	   	  tdim.array)   
 	  dmp.vcr.rule.elements.from.arrays(   
 	   	  bcstf008.cdca,   
 	   	  dim.options,   
 	   	  var.cvr.udim1,   
 	   	  var.cvr.udim2,   
 	   	  var.cvr.udim3,   
 	   	  var.cvr.udim4,   
 	   	  var.cvr.udim5,   
 	   	  array.depth,   
 	   	  nof.elements,   
 	   	  fdim.array,   
 	   	  tdim.array)   
 	   	   	   	   	   	   	   	   	  |# FP10.en   
 	     
 	  dump 3 |   *  Currency Difference Contra account is added.
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	   	   	   	   	   	   	  |# FP10.sn   
 	   	  var.cvr.udim1  =  ""  	   	   	   	   	   	     
 	   	  var.cvr.udim2  =  ""  	   	   	   	   	   	     
 	   	  var.cvr.udim3  =  ""  	   	   	   	   	   	     
 	   	  var.cvr.udim4  =  ""  	   	   	   	   	   	     
 	   	  var.cvr.udim5  =  ""   
 	   	  dim.options(1)  =  tfgld008.dim1   
 	   	  dim.options(2)  =  tfgld008.dim2   
 	   	  dim.options(3)  =  tfgld008.dim3   
 	   	  dim.options(4)  =  tfgld008.dim4   
 	   	  dim.options(5)  =  tfgld008.dim5   
 	   	  nof.elements  =  0   
 	   	  set.mem(fdim.array, "")   
 	   	  set.mem(tdim.array, "")   
 	   	  convert.dimension.ranges.to.cvr.rule(   
 	   	   	  tfgld008.leac,   
 	   	   	  dim.options,   
 	   	   	  array.depth,   
 	   	   	  nof.elements,   
 	   	   	  fdim.array,   
 	   	   	  tdim.array)   
 	   	  dmp.vcr.rule.elements.from.arrays(   
 	   	   	  tfgld008.leac,   
 	   	   	  dim.options,   
 	   	   	  var.cvr.udim1,   
 	   	   	  var.cvr.udim2,   
 	   	   	  var.cvr.udim3,   
 	   	   	  var.cvr.udim4,   
 	   	   	  var.cvr.udim5,   
 	   	   	  array.depth,   
 	   	   	  nof.elements,   
 	   	   	  fdim.array,   
 	   	   	  tdim.array)   
 	   	   	   	   	   	   	   	  |# FP10.en   
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:008
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:tf
:SCMOD:gld
:SFLNO:009
:ICOD:D
:QURY:START
	  |   *  Delibirate use of tccvat to set var.max.dimension.   
 	  |   *  Domain tccvat at BaanIV side is the same as domain tfgld.dimx at ERP LN side.   
 	  | set.fmax(var.max.dimension, "tccvat")    
 	  if tfgld009.udim  =  var.max.dimension(1;6) then   
 	   	  var.tfgld009.udim  =  get.string(57) |   *  ZZZZZZZZZ   
 	  else   
 	   	  var.tfgld009.udim  =  tfgld009.udim   
 	  endif   
 	  dump 6 |   *  Existing dimension ranges
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:011
:SCPAC:tf
:SCMOD:gld
:SFLNO:011
:ICOD:D
:QURY:START
|  *  test   
 	  convert.session.code(   
 	   	  tfgld011.ses1,   
 	   	  tfgld011.ses2,   
 	   	  var.tfgld011.ses1,   
 	   	  var.tfgld011.ses2)   
 	  |   *  Logic extracted from SPT (tfspt.dll0933)   
 	  if tfgld011.cpst  =  empty then   
 	   	  var.tfgld011.cpst  =  target(tcynna.not.app)   
 	  else   
 	   	  if tfgld011.catg  <>  tfgld.catg.sales.cred   
 	   	  and tfgld011.catg  <>  tfgld.catg.purchase.cred then   
 	   	   	  var.tfgld011.cpst  =  target(tcynna.not.app)   
 	   	  else   
 	   	   	  on case tfgld011.cpst   
 	   	   	  case tcyesno.no:   
 	   	   	   	  var.tfgld011.cpst  =  target(tcynna.no)   
 	   	   	   	  break   
 	   	   	  case tcyesno.yes:   
 	   	   	   	  var.tfgld011.cpst  =  target(tcynna.yes)   
 	   	   	   	  break   
 	   	   	  endcase   
 	   	  endif   
 	  endif   
 	     
 	  if tfgld011.appr  =  empty then   
 	   	  var.tfgld011.appr  =  target(tfacp.inv.na)   
 	  else   
 	   	  if tfgld011.catg  <>  tfgld.catg.purchase.inv   
 	   	  and tfgld011.catg  <>  tfgld.catg.purchase.cred then   
 	   	   	  var.tfgld011.appr  =  target(tfacp.inv.na)   
 	   	  else   
 	   	   	  on case tfgld011.appr   
 	   	   	  case tfacp.matc.pur :   
 	   	   	   	  var.tfgld011.appr  =  target(tfacp.inv.purchase)   
 	   	   	   	  |   *  Invoice related to Purchase Orders   
 	   	   	   	  break   
 	   	   	  default :  	   	     
 	   	   	   	  var.tfgld011.appr  =  target(tfacp.inv.expence)   
 	   	   	   	  |   *  Cost Invoice   
 	   	   	   	  break   
 	   	   	  endcase   
 	   	  endif   
 	  endif   
 	  if tfgld011.dfmt.l  =  empty then   
 	   	  var.tfgld011.dfmt  =  target(tfgld.dfmt.na)   
 	  else   
 	   	  if (tfgld011.catg  <>  tfgld.catg.journals   
 	   	  and tfgld011.catg  <>  tfgld.catg.recurr.journ)   
 	   	  or not isspace(tfgld011.apnt.l)   
 	   	  or not isspace(tfgld011.qpnt.l) then   
 | 	   	   	  var.tfgld011.dfmt  =  target(tfgld.dfmt.na) |#1835658.o   
 	   	   	  var.tfgld011.dfmt  =  etol(tfgld011.dfmt.l) |#1835658.n   
 	   	  else   
 | 	   	   	  var.tfgld011.dfmt  =  etol(tfgld011.dfmt.l) |#1835658.o   
 	   	   	  var.tfgld011.dfmt  =  target(tfgld.dfmt.na) |#1835658.n   
 	   	  endif   
 	  endif   
 	  if tfgld011.catg  =  empty then   
 	   	  var.tfgld011.catg  =  target(tfgld.catg.not.applicable)   
 	  else   
 	   	  var.tfgld011.catg  =  etol(tfgld011.catg)   
 	  endif   
 	   	   	   	   	   	   	   	  |# FP10.sn   
 	  var.sub.category  =  get.default.transaction.sub.category(   
 	   	   	   	  ltoe(var.tfgld011.catg),   
 	   	   	   	  var.tfgld011.ses1)   
 	   	   	   	   	   	   	   	  |# FP10.en   
 	     
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:011
:SCPAC:tf
:SCMOD:gld
:SFLNO:011
:ICOD:S
:QURY:START
select  	  tfgld011.*     
from 	  tfgld011
:QURY:END
:TEXT:
Domain change for tfgld011.cpst, from tcyesno to tcynna. 
In case the field was empty or not an credit note category, it is set to not applicable. 

Fields tfgld011.appr and tfgld011.dfmt are defaulted in case they are empty.
:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:011
:SCPAC:tf
:SCMOD:gld
:SFLNO:011
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:018
:SCPAC:tf
:SCMOD:gld
:SFLNO:018
:ICOD:D
:QURY:START
	  for element  =  1 to 3   
 	   	  var.tfgld018.rate(element)  =  fill.mc.field.double(   
 	   	   	   	  tfgld018.rate,   
 	   	   	   	  element,   
 	   	   	   	  0.000001)  	     
 	   	  var.tfgld018.ratf(element)  =  fill.mc.field.long(   
 	   	   	   	  tfgld018.ratf,   
 	   	   	   	  element,   
 	   	   	   	  1)  	     
 	  endfor   
 	     
 	  determine.exchange.rate.type(   
 	   	  var.str.pur.rtyp,   
 	   	  var.str.sls.rtyp,   
 	   	  var.str.eu.rtyp,   
 	   	  current.company,   
 	   	  tfgld018.ttyp,   
 	   	  tfgld018.docn,   
 	   	  tfgld018.year,   
 	   	  tfgld018.btno,   
 	   	  tfgld018.trun,   
 	   	  var.tfgld018.rtyp)   
 	  if not isspace(tfgld018.ccty) then  	   	   	  |# SP2.sn   
 	   	  var.tfgld018.ccty  =  get.country.of.financial.company(   
 	   	   	   	   	  current.company)   
 	  endif  	   	   	   	   	   	   	  |# SP2.en   
 	     
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:018
:SCPAC:tf
:SCMOD:gld
:SFLNO:018
:ICOD:S
:QURY:START
select  	  tfgld018.*    
from 	  tfgld018
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:018
:SCPAC:tf
:SCMOD:gld
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:S
:QURY:START
select tfgld102.*   
from tfgld102
:QURY:END
:TEXT:
New fields tfgld102.oira, oiah, oiam, oicr, oirf, oirt and taby set to default().
:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  if not isspace(tfgld106.ccty) then  	    	    	   | # 1359481.n   
 	    	  if tfgld106.vtyp  =  empty and  	    	    	    	   | # 239383.sn   
 	    	  double.cmp( tfgld106.vamt, 0.0, 0.0001)  =  0 then  	     
 	    	    	  var.tfgld106.ccty  =  tfgld106.ccty  	    	     
 	    	    	  var.tfgld106.cvat  =  ""   	     	     	     	      
 	    	  else  	    	    	    	    	    	    	   | # 239383.en   
 	    	    	    	    	    	    	    	   | # 239383.so   
 |   	    	   |   *  PERF: Minimize calls to function   
 |   	    	   |   *  function below activate again  	    	   | # 210859.n   
 |   	    	  if prev.tfgld106.ccty  <>  tfgld106.ccty or   
 |   	    	  prev.tfgld106.cvat  <>  tfgld106.cvat or   
 |   	    	  prev.tfgld106.ocmp  <>  tfgld106.ocmp then   
 	    	    	    	    	    	    	    	   | # 239383.eo   
 	    	    	    	    	    	    	    	   | # 210859.so   
 	   |   	    	  ret.long  =  get.tax.by.country.code(   
 	   |   	    	    	  tfgld106.ccty,   
 	   |   	    	    	  tfgld106.cvat,   
 	   |   	    	    	  var.tfgld106.ccty,   
 	   |   	    	    	  var.tfgld106.cvat,   
 	   |   	    	    	  error.message)   
 	    	    	    	    	    	    	    	   | # 210859.eo   
 	    	    	    	    	    	    	    	   | # 210859.sn   
 	     
 	    	    	  ret.long  =  get.tax.by.country.code.and.financial.company(   
 	    	    	    	  tfgld106.ccty,   
 	    	    	    	  tfgld106.cvat,   
 	    	    	    	  tfgld106.ocmp,   
 	    	    	    	  var.tfgld106.ccty,   
 	    	    	    	  var.tfgld106.cvat,   
 	    	    	    	  error.message)   
 	    	    	    	    	    	    	    	   | # 210859.en   
 	    	    	    	    	    	    	    	   | # 239383.so   
 |   	    	    	  prev.tfgld106.ccty  =  tfgld106.ccty   
 |   	    	    	  prev.tfgld106.cvat  =  tfgld106.cvat   
 |   	    	    	  prev.tfgld106.ocmp  =  tfgld106.ocmp  	   | # 210859.n   
 |   	    	  endif   
 	    	  endif  	    	    	    	    	    	   | # 1359481.sn   
 	  else  	     
 	    	  var.tfgld106.ccty  =  tfgld106.ccty  	    	     
 	    	  var.tfgld106.cvat  =  tfgld106.cvat  	    	   | # 1359481.en   
 	    	    	    	    	    	    	    	   | # 239383.eo   
 	  endif  	    	    	    	    	    	    	   | # 239383.n   
 	    	    	    	    	    	    	    	   | # 210859.so   
 	    	    	    	    	    	    	    	   | # SP2.sn   
 |   	  if not isspace(tfgld106.ccty) then   
 |   	    	  var.tfgld106.ccty  =  get.country.of.financial.company(   
 |   	    	    	    	    	  tfgld106.ocmp)   
 |   	  endif  	    	    	    	    	    	    	   | # SP2.en   
 	    	    	    	    	    	    	    	   | # 210859.eo   
 	  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  	     
 	  if tfgld106.catg  =  empty then   
 	    	  var.tfgld106.catg  =  target(tfgld.catg.not.applicable)   
 	  else   
 	    	  var.tfgld106.catg  =  etol(tfgld106.catg)   
 	  endif  	    	     
 	  dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:107
:SCPAC:tf
:SCMOD:gld
:SFLNO:107
:ICOD:D
:QURY:START
| 	 ret.long  =  get.tax.by.country.code( 	  	  	 |# SP2.so   
 | 	  	  	 tfgld107.ccty,   
 | 	  	  	 tfgld107.cvat,   
 | 	  	  	 var.tfgld107.ccty,   
 | 	  	  	 var.tfgld107.cvat,   
 | 	  	  	 error.message) 	  	  	 |# SP2.eo   
 	 var.tfgld107.ccty  =  ""  	   	   	   	  |# 210859.n    
 	 var.tfgld107.cvat  =  ""  	   	   	   	  |# 210859.n    
 	 if not isspace(tfgld107.ccty) then 	  	 |# SP2.sn   
 	  	  	  	  	  	  	 |# 210859  -  2.so   
 | 	  	 var.tfgld107.ccty  =  get.country.of.financial.company(   
 | 	  	  	  	  	 tfgld107.cono)   
 	  	  	  	  	  	  	 |# 210859  -  2.eo   
 	  	  	  	  	  	  	  	 |# 210859.so   
 | 	  	 ret.long  =  get.tax.by.country.code(   
 | 	  	  	  	 tfgld107.ccty,   
 | 	  	  	  	 tfgld107.cvat,   
 | 	  	  	  	 var.tfgld107.ccty,   
 | 	  	  	  	 var.tfgld107.cvat,   
 | 	  	  	  	 error.message)   
 	  	  	  	  	  	  	  	 |# 210859.eo   
 	  	  	  	  	  	  	  	 |# 210859.sn   
 	  	 ret.long  =  get.tax.by.country.code.and.financial.company(   
 	  	  	  	 tfgld107.ccty,   
 	  	  	  	 tfgld107.cvat,   
 	  	  	  	 tfgld107.cono,   
 	  	  	  	 var.tfgld107.ccty,   
 	  	  	  	 var.tfgld107.cvat,   
 	  	  	  	 error.message)   
 	  	  	  	  	  	  	  	 |# 210859.en   
 	 endif 	  	  	  	  	  	  	 |# SP2.en   
 	    
 	 var.tfgld107.orno  =  convert.number(bcckon.act.pur, tfgld107.orno)   
 	 for element  =  1 to 3   
 	  	 var.tfgld107.vamh(element)  =  fill.mc.field.double(   
 	  	  	  	 tfgld107.vamh,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	    
 	 endfor   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:107
:SCPAC:tf
:SCMOD:gld
:SFLNO:107
:ICOD:S
:QURY:START
select 	 tfgld107.*     
from 	 tfgld107
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:107
:SCPAC:tf
:SCMOD:gld
:SFLNO:107
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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( 	  	  	 |# SP2.so   
 | 	  	  	 tfgld110.ccty,   
 | 	  	  	 tfgld110.cvat,   
 | 	  	  	 var.tfgld110.ccty,   
 | 	  	  	 var.tfgld110.cvat,   
 | 	  	  	 error.message) 	  	  	 |# SP2.eo   
 	 var.tfgld110.ccty  =  ""  	    	    	    	  |# 210859.n     
 	 var.tfgld110.cvat  =  ""  	    	    	    	  |# 210859.n     
 	 if not isspace(tfgld110.ccty) then 	  	  	 |# SP2.sn   
 	  	  	  	  	  	  	  	 |# 210859.so   
 | 	  	 var.tfgld110.ccty  =  get.country.of.financial.company(   
 | 	  	  	  	  	 tfgld110.cono)   
 	  	  	  	  	  	  	  	 |# 210859.eo   
 	  	  	  	  	  	  	  	 |# 210859.so   
 | 	  	 ret.long  =  get.tax.by.country.code( 	 |# 210859.sn   
 | 	  	  	  	 tfgld110.ccty,   
 | 	  	  	  	 tfgld110.cvat,   
 | 	  	  	  	 var.tfgld110.ccty,   
 | 	  	  	  	 var.tfgld110.cvat,   
 | 	  	  	  	 error.message) 	  	 |# 210859.en   
 	  	  	  	  	  	  	  	 |# 210859.eo   
 	  	  	  	  	  	  	  	 |# 210859.sn   
 	  	 ret.long  =  get.tax.by.country.code.and.financial.company(   
 	  	  	  	 tfgld110.ccty,   
 	  	  	  	 tfgld110.cvat,   
 	  	  	  	 tfgld110.cono,   
 	  	  	  	 var.tfgld110.ccty,   
 	  	  	  	 var.tfgld110.cvat,   
 	  	  	  	 error.message)   
 	  	  	  	  	  	  	  	 |# 210859.en   
 	 endif 	  	  	  	  	  	  	 |# SP2.en   
 	 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 	    
 	 if tfgld110.catg  =  empty then   
 	  	 var.tfgld110.catg  =  target(tfgld.catg.not.applicable)   
 	 else   
 	  	 var.tfgld110.catg  =  etol(tfgld110.catg)   
 	 endif 	    
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:450
:SCPAC:tf
:SCMOD:gld
:SFLNO:450
:ICOD:D
:QURY:START
	 var.tfgld450.indt  =  utc(0,0) 	  	  	  	 |# LN 10.6.sn   
 	 var.tfgld450.dsca  =  form.text$("bcstc00035") 	  	 |   *  Actual Set   
 	 dump 1   
 	 var.tfgld450.indt  =  utc(date.num(), time.num())   
 	 var.tfgld450.dsca  =  form.text$("bcstc00036") 	  	 |   *  Converted from BaanIVc4   
 	  	  	  	  	  	  	  	 |# LN 10.6.en   
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:473
:SCPAC:bc
:SCMOD:stf
:SFLNO:000
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:473
:SCPAC:bc
:SCMOD:stf
:SFLNO:000
:ICOD:S
:QURY:START
select 	 bcstf000.*    
from 	 bcstf000
where 	 bcstf000._index1  =  {1}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:473
:SCPAC:bc
:SCMOD:stf
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  set.var.tibom010.sizu(tibom010.leng, tibom010.widt) 	 |#10.5.1.n   
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:bom
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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 |# 228333.o   
 	  if tipcs022.opol  =  tcittb.standard then |# 228333.n   
 	   	  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   
 	 set.var.tibom010.sizu(tipcs022.leng, tipcs022.widt) 	 |#10.5.1.n   
 	     
 |# 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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:bom
:TFLNO:010
:SCPAC:ti
:SCMOD:pcs
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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 item   
 	  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   
 	 set.var.tibom010.sizu(tipcs110.leng, tipcs110.widt) 	 |#10.5.1.n   
 	     
 	  |   *  dump   
 	  dump 3   
 	  |   *  store current item code   
 	  prev.item  =  tipcs110.item
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:009
:SCPAC:bc
:SCMOD:sti
:SFLNO:006
:ICOD:D
:QURY:START
	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:009
:SCPAC:bc
:SCMOD:sti
:SFLNO:006
:ICOD:S
:QURY:START
select bcsti006.*    
from 	  bcsti006
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:009
:SCPAC:bc
:SCMOD:sti
:SFLNO:006
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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) |  *  bcintdll0000   
 	 var.ticpr010.chrt  =  bcsti008.chrt 	  	  	 |#10.6.sn   
 	 var.ticpr010.cpcp  =  bcstc006.cost   
 	 var.ticpr010.cref  =  etol(bcstc006.cref)   
 	 var.ticpr010.cpus  =  10 	 |Detail (Component Type)   
 	 var.ticpr010.sccl  =  3 	 |Not Applicable (Collect in Scheme)   
 	  	  	  	  	  	  	  	 |#10.6.en   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:008
:ICOD:S
:QURY:START
select bcsti008.*     
from 	 bcsti008 |  *  Mappings for Cost Component Chart Details
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:012
:ICOD:D
:QURY:START
	 |  *  Aggregated and Collect cost components record made current.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:012
:ICOD:S
:QURY:START
select bcsti012.*  |  *  default Agg. and Collect cost components |#10.6.sn   
from bcsti012
where bcsti012._index1  =  {1}
as set with 1  rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:010
:SCPAC:bc
:SCMOD:sti
:SFLNO:012
:ICOD:X
:QURY:START
select bcsti006.*   |  *  Mappings for Cost Component Chart   
 from bcsti006   
 selectdo   
 	 |  *  For every chart, insert the four Aggregated and four   
 	 |  *  Collect cost components   
 	 var.ticpr010.chrt  =  bcsti006.chrt |Scheme   
 	    
 	 var.ticpr010.cpcp  =  bcsti012.aggm   
 	 var.ticpr010.cref  =  2 |Material (Cost Component Type)   
 	 var.ticpr010.cpus  =  30 |Aggregated (Component Type)   
 	 var.ticpr010.sccl  =  3 |Not Applicable (Collect in scheme)   
 	 dump 1   
 	 var.ticpr010.cpcp  =  bcsti012.aggo   
 	 var.ticpr010.cref  =  1 |Operation   
 	 var.ticpr010.cpus  =  30 |Aggregated   
 	 var.ticpr010.sccl  =  3 |Not Applicable   
 	 dump 1   
 	    
 	 var.ticpr010.cpcp  =  bcsti012.aggs   
 	 var.ticpr010.cref  =  4 |Surcharge   
 	 var.ticpr010.cpus  =  30 |Aggregated   
 	 var.ticpr010.sccl  =  3 |Not Applicable   
 	 dump 1   
 	 var.ticpr010.cpcp  =  bcsti012.aggg   
 	 var.ticpr010.cref  =  6 |General   
 	 var.ticpr010.cpus  =  30 |Aggregated   
 	 var.ticpr010.sccl  =  3 |Not Applicable   
 	 dump 1   
 	    
 	 var.ticpr010.cpcp  =  bcsti012.colm   
 	 var.ticpr010.cref  =  2 |Material   
 	 var.ticpr010.cpus  =  20|Collect   
 	 var.ticpr010.sccl  =  1 |Yes   
 	 dump 1   
 	    
 	 var.ticpr010.cpcp  =  bcsti012.colo   
 	 var.ticpr010.cref  =  1 |Operation   
 	 var.ticpr010.cpus  =  20|Collect   
 	 var.ticpr010.sccl  =  1 |Yes   
 	 dump 1   
 	    
 	 var.ticpr010.cpcp  =  bcsti012.cols   
 	 var.ticpr010.cref  =  4 |Surcharge   
 	 var.ticpr010.cpus  =  20|Collect   
 	 var.ticpr010.sccl  =  1 |Yes   
 	 dump 1   
 	    
 	 var.ticpr010.cpcp  =  bcsti012.colg   
 	 var.ticpr010.cref  =  6 |General   
 	 var.ticpr010.cpus  =  20|Collect   
 	 var.ticpr010.sccl  =  1 |Yes   
 	 dump 1   
 	    
 endselect   
 	  	  	  	  	  	  	 |#10.6.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:100
:SCPAC:ti
:SCMOD:cpr
:SFLNO:100
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:100
:SCPAC:ti
:SCMOD:cpr
:SFLNO:100
:ICOD:S
:QURY:START
select ticpr100.*   
from ticpr100
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:100
:SCPAC:ti
:SCMOD:cpr
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:170
:SCPAC:ti
:SCMOD:cpr
:SFLNO:170
:ICOD:D
:QURY:START
	  get.cost.components(bcorig.ticpr, ticpr170.cpcp, "", tmp.errmess)   
 	  var.ticpr170.cpcp  =  bcstc006.cost   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:170
:SCPAC:ti
:SCMOD:cpr
:SFLNO:170
:ICOD:S
:QURY:START
select ticpr170.*   
from ticpr170
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:170
:SCPAC:ti
:SCMOD:cpr
:SFLNO:170
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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(   
 	   	   	   	   	  prev.kitm)  	   	  |# 1391462.n   
 |  	   	   	   	   	  tmp.kitm) |# 237409.n  	  |# 1391462.o   
 	   	   	     
 	   	   	  |   *  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   
 	     
 	  |  *  Not allowed to have ticpr200 records linked to Subcontracting items.   
 	  |  *  these records leads to errors in LN and therefore are skipped during migration   
 	  |  *  Also in BaanIVsp15 considered as bad data not possible to create cost price   
 	  |  *  records for subcontracting items using standard sessions.   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  var.cpcc  =  ticpr200.cpcc  	  |# 210805.n   
 	   	  prev.item  =  ticpr200.item  	  |# 210805.n   
 	   	  prev.kitm  =  tmp.kitm  	   	   	   	  	 |#1391462.n   
 	   	  var.item   =  "" 	  	  	  	  	  	 |#1949214.n   
 	   	  ticpr200.records.skipped  =  ticpr200.records.skipped  +  1 	 |#1949214.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   
 	  prev.kitm  =  tmp.kitm  	   	   	   	   	  |# 1391462.n  	     
 	     
 	  |   *  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(   
 	   	   	   	  tmp.kitm) |# 237409.n   
 	     
 	   	  |   *  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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(   
 	   	   	  tmp.kitm) |# 237409.n   
 	     
 	  |   *  dump ticpr206 (Cost Comp Struct) only for   
 	  |   *  standard calc. code   
 	  if var.cpcc  =  ticpr000.sccc then   
 	   	  dump.8.ticpr206.aggr.cpcp()   
 	  endif   
 	  	    
 	  	  	  	  	  	  	  	  	  	 |#1949214.sn   
 	  if ticpr200.records.skipped  >  0 then   
 	  	 |  *  Log error message in bcrun999 when records of ticpr200 are skipped.   
 	  	 log.error.data("Skipped ticpr200 records related to Subcontracting items: "  &     
 	  	  	  	 str$(ticpr200.records.skipped))   
 	  endif   
 	  	  	  	  	  	  	  	  	  	 |#1949214.en 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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.7.ticpr306.aggr.cpcp()   
 	   	   	  dump.10.ticpr340.aggr.cpcp(   
 	   	   	   	   	  prev.kitm)  	   	  |# 1391462.n   
 |  	   	   	   	   	  tmp.kitm) |# 237409.n  	  |# 1391462.o   
 	   	  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   
 	     
 	  |  *  Not allowed to have ticpr300 records linked to Subcontracting items.   
 	  |  *  these records leads to errors in LN and therefore are skipped during migration   
 	  |  *  Also in BaanIVsp15 considered as bad data not possible to create cost price   
 	  |  *  records for subcontracting items using standard sessions.   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  prev.item  =  ticpr300.item  	  |# 210805.n   
 	   	  var.indt  =  ticpr300.indt  	  |# 210805.n   
 	   	  var.item   =  "" 	  	  	  	  	  	 |#1949214.n   
 	   	  ticpr300.records.skipped  =  ticpr300.records.skipped  +  1 	 |#1949214.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   
 	  prev.kitm  =  tmp.kitm  	   	   	   	   	  |# 1391462.n   
 	     
 	  |   *  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.7.ticpr306.eff.cpcp()   
 	   	  dump.10.ticpr340.eff.cpcp(   
 	   	   	   	  tmp.kitm) |# 237409.n   
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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(   
 	   	   	  tmp.kitm) |# 237409.n   
 	   	   	    
 	  	  	  	  	  	  	  	  	  	 |#1949214.sn   
 	  if ticpr300.records.skipped  >  0 then   
 	  	 |  *  Log error message in bcrun999 when records of ticpr300 are skipped.   
 	  	 log.error.data("Skipped ticpr300 records related to Subcontracting items: "  &     
 	  	  	  	 str$(ticpr300.records.skipped))   
 	  endif   
 	  	  	  	  	  	  	  	  	  	 |#1949214.en 	   	   	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:cpr
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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.8.ticpr206.aggr.cpcp()   
 	   	   	  dump.9.ticpr240.aggr.cpcp(   
 	   	   	   	   	  tmp.kitm) |# 237409.n   
 	   	  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   
 	     
 	  |  *  Not allowed to have costprice records linked to Subcontracting items.   
 	  |  *  these records leads to errors in LN and therefore are skipped during migration   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  var.item  =  tmp.item  	   	  |# 210805.n   
 	   	  var.item   =  "" 	  	  	  	  	  	 |#1949214.n   
 	   	  tipcs150.records.skipped  =  tipcs150.records.skipped  +  1 	 |#1949214.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.8.ticpr206.eff.cpcp()   
 	   	  dump.9.ticpr240.eff.cpcp(   
 	   	   	  tmp.kitm) |# 237409.n   
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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.8.ticpr206.aggr.cpcp()   
 	  dump.9.ticpr240.aggr.cpcp(   
 	   	   	  tmp.kitm) |# 237409.n   
 	  	  	  	  	  	  	  	  	  	 |#1949214.sn   
 	  if tipcs150.records.skipped  >  0 then   
 	  	 |  *  Log error message in bcrun999 when records of tipcs150 are skipped.   
 	  	 log.error.data("Skipped tipcs150 records related to Subcontracting items: "  &     
 	  	  	  	 str$(tipcs150.records.skipped))   
 	  endif   
 	  	  	  	  	  	  	  	  	  	 |#1949214.en 	   	   	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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(   
 	   	   	   	   	  prev.kitm)  	   	  |# 1391462.n   
 |  	   	   	   	   	  tmp.kitm) |# 237409.n  	  |# 1391462.o   
 	   	   	   	   	   	     
 	   	   	     
 	   	   	  |   *  also create Standard Cost Price   
 	   	   	  dump.5.ticpr301()   
 	   	   	  dump.4.ticpr300.aggr.cpcp()   
 	   	   	  dump.7.ticpr306.aggr.cpcp()   
 	   	   	  dump.10.ticpr340.aggr.cpcp(   
 	   	   	   	   	  prev.kitm)  	   	  |# 1391462.n   
 |  	   	   	   	   	  tmp.kitm) |# 237409.n  	  |# 1391462.o   
 	   	  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   
 	     
 	  |  *  Not allowed to have costprice records linked to Subcontracting items.   
 	  |  *  these records leads to errors in LN and therefore are skipped during migration.   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  var.item  =  tmp.item  	  |# 210805.n   
 	   	  prev.kitm  =  tmp.kitm  	   	   	   	  |# 1391462.n   
 	   	  var.item   =  "" 	  	  	  	  	  	 |#1949214.n   
 	   	  tipcs350.records.skipped  =  tipcs350.records.skipped  +  1 	 |#1949214.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   
 	  prev.kitm  =  tmp.kitm  	   	   	   	  |# 1391462.n   
 |  	  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(   
 	   	   	  tmp.kitm) |# 237409.n  	     
 	     
 	   	  dump.4.ticpr300.eff.cpcp()   
 	   	  dump.7.ticpr306.eff.cpcp()   
 	   	  dump.10.ticpr340.eff.cpcp(   
 	   	   	  tmp.kitm) |# 237409.n  	     
 	   	     
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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(   
 	   	   	  tmp.kitm) |# 237409.n  	     
 	     
 	  |   *  also create Standard Cost Price   
 	  dump.5.ticpr301()   
 	  dump.4.ticpr300.aggr.cpcp()   
 	  dump.7.ticpr306.aggr.cpcp()   
 	  dump.10.ticpr340.aggr.cpcp(   
 	   	   	  tmp.kitm) |# 237409.n   
 	  	  	  	  	  	  	  	  	  	 |#1949214.sn   
 	  if tipcs350.records.skipped  >  0 then   
 	  	 |  *  Log error message in bcrun999 when records of tipcs350 are skipped.   
 	  	 log.error.data("Skipped tipcs350 records related to Subcontracting items: "  &     
 	  	  	  	 str$(tipcs350.records.skipped))   
 	  endif   
 	  	  	  	  	  	  	  	  	  	 |#1949214.en   
 	   	   	   	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:200
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:220
:SCPAC:ti
:SCMOD:cpr
:SFLNO:220
:ICOD:S
:QURY:START
select 	 ticpr220.*    
from 	 ticpr220
where 	 ticpr220.cntr  =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:220
:SCPAC:ti
:SCMOD:cpr
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:230
:SCPAC:ti
:SCMOD:cpr
:SFLNO:230
:ICOD:S
:QURY:START
select ticpr230.*    
from ticpr230
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:230
:SCPAC:ti
:SCMOD:cpr
:SFLNO:230
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:320
:SCPAC:ti
:SCMOD:cpr
:SFLNO:320
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:330
:SCPAC:ti
:SCMOD:cpr
:SFLNO:330
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:001
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:D
:QURY:START
	  	  	  	  	 |#10.5.1.sn   
 	 if ticst001.leng  >  0.0001 or ticst001.widt  >  0.00001 then   
 	  	 var.ticst001.sizu  =  tibom000.buom   
 	 else   
 	  	 var.ticst001.sizu  =  ""   
 	 endif 	  	  	  	  	  	  	    
 	  	  	  	  	 |#10.5.1.en   
 	     
 |# SP2.sn  	     
 	  |   *  Read Item Data   
 	  select  	  tiitm001.pics, tiitm001.kltc   
 	  from  	  tiitm001   
 	  where  	  tiitm001._index1  =  {:ticst001.sitm}   
 	  as set with 1 rows   
 	  selectdo   
 	  endselect   
 |# SP2.en   
 	  |   *  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   
 |# SP2.sn   
 	  if tiitm001.pics  =  tcyesno.yes then   
 	   	  var.ticst001.drin  =  tcyesno.yes   
 	   	  var.ticst001.dris  =  tcyesno.yes   
 	  endif   
 |# SP2.en   
 |# SP2.so   
 |  	  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   
 |# SP2.eo   
 	     
 	  |   *  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   
 	   	   	     
 |  	  |   *  Allocation Type  	   	   	   	   	   	  |# 1132004.so   
 |  	  if tiitm001.kltc  =  tckltc.none then  	   	   	   	     
 |  	   	  var.ticst001.alty  =  target(tialty.both)   
 |  	  else   
 |  	   	  if ticst001.ques  <  0.0 then   
 |  	   	   	  var.ticst001.alty  =  target(tialty.output)   
 |  	   	  else   
 |  	   	   	  var.ticst001.alty  =  target(tialty.input)   
 |  	   	  endif   
 |  	  endif  	   	   	   	   	   	   	   	  |# 1132004.eo   
 	  |   *  Allocation Type  	   	   	   	   	   	  |# 1132004.sn   
 	  if ticst001.ques  <  0.0 then   
 	   	  var.ticst001.alty  =  target(tialty.output)   
 	  else   
 	   	  var.ticst001.alty  =  target(tialty.input)   
 	  endif  	   	   	   	   	   	   	   	  |# 1132004.en   
 	     
 	  dump 999   
 	     
 	  |   *  set previous production order   
 	  prev.pdno  =  ticst001.pdno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:001
:SCPAC:ti
:SCMOD:cst
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:021
:SCPAC:ti
:SCMOD:cst
:SFLNO:021
:ICOD:D
:QURY:START
	 if not isspace (tisfc001.cprj) then   
 	  	 var.ticst021.cprj  =  get.ti.project(tisfc001.cprj)   
 	 else   
 	  	 var.ticst021.cprj  =  empty()   
 	 endif   
 	 for element  =  1 to 3   
 	  	 var.ticst021.copr(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst021.copr,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst021.mccs(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst021.mccs,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst021.mces(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst021.mces,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	 endfor   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:021
:SCPAC:ti
:SCMOD:cst
:SFLNO:021
:ICOD:S
:QURY:START
select 	 ticst021.*  , tisfc001.cprj  
from 	 ticst021, tisfc001
where 	 tisfc001.pdno  =  ticst021.pdno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:021
:SCPAC:ti
:SCMOD:cst
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:022
:SCPAC:ti
:SCMOD:cst
:SFLNO:022
:ICOD:D
:QURY:START
	 for element  =  1 to 3   
 	  	 var.ticst022.wces(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.wces,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.mces(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.mces,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.oces(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.oces,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.sces(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.sces,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.wccs(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.wccs,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.mccs(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.mccs,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.occs(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.occs,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	  	 var.ticst022.sccs(element)  =  fill.mc.field.double(   
 	  	  	  	 ticst022.sccs,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	   
 	 endfor   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:022
:SCPAC:ti
:SCMOD:cst
:SFLNO:022
:ICOD:S
:QURY:START
select ticst022.*   
from ticst022
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:022
:SCPAC:ti
:SCMOD:cst
:SFLNO:022
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:030
:SCPAC:ti
:SCMOD:cst
:SFLNO:030
:ICOD:D
:QURY:START
	  |   *  NB. join of ticst030 and tisfc001 in 1 select   
 	  |   *  resulted in very bad performance   
 	  if ticst030.pdno  <>  prev.pdno then   
 	   	  project  =  " "   
 	   	  select  	  tisfc001.cprj:project   
 	   	  from  	  tisfc001   
 	   	  where  	  tisfc001._index1  =  {:ticst030.pdno}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 	  endif   
 	  |   *  get mapped project   
 	  if not isspace (project) then   
 	   	  var.ticst030.cprj  =  get.ti.project(project)   
 	  else   
 	   	  var.ticst030.cprj  =  empty()   
 	  endif   
 	  |   *  dump data for ticst030   
 	  dump 1 |   *  ticst030   
 	  |   *  save current production order   
 	  prev.pdno  =  ticst030.pdno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:030
:SCPAC:ti
:SCMOD:cst
:SFLNO:030
:ICOD:S
:QURY:START
select  	  ticst030.*    	   	   	   	   	   	   	  |# 1421630.sn   
from 	  ticst030
order by ticst030._index1 |   *  mitm, pdno, opno
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cst
:TFLNO:030
:SCPAC:ti
:SCMOD:cst
:SFLNO:030
:ICOD:X
:QURY:START
	   	   	   	   	   	   	   	   	  |# 1421630.en   
 	   	   	   	   	   	   	   	   	  |# 1421630.so   
 | select  	  ticst030.*     
 | from  	  ticst030   
 | order by ticst030._index1  	  |   *  mitm, pdno, opno   
 | selectdo   
 |  	  |   *  NB. join of ticst030 and tisfc001 in 1 select   
 |  	  |   *  resulted in very bad performance   
 |  	  if ticst030.pdno  <>  prev.pdno then   
 |  	   	  select  	  tisfc001.cprj   
 |  	   	  from  	  tisfc001   
 |  	   	  where  	  tisfc001.pdno  =  :ticst030.pdno   
 |  	   	  selectdo   
 |  	   	  endselect   
 |  	  endif   
 |  	     
 |  	  |   *  get mapped project   
 |  	  if not isspace (tisfc001.cprj) then   
 |  	   	  var.ticst030.cprj  =  get.ti.project(tisfc001.cprj)   
 |  	  else   
 |  	   	  var.ticst030.cprj  =  empty()   
 |  	  endif   
 |  	     
 |  	  |   *  dump data   
 |  	  dump 1   
 |  	  |   *  save current production order   
 |  	  prev.pdno  =  tisfc001.pdno   
 | endselect   
 	   	   	   	   	   	   	   	   	  |# 1421630.eo
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:010
:SCPAC:ti
:SCMOD:edm
:SFLNO:010
:ICOD:D
:QURY:START
	 |  *  revision series: use first 3 postion of last revision   
 	 var.tiedm100.revi  =  ""    
 	 select tiedm100.revi   
 	 from 	 tiedm100   
 	 where 	 tiedm100.eitm  =  :tiedm010.eitm   
 	 order by tiedm100.revi desc   
 	 as set with 1 rows   
 	 selectdo   
 	  	 var.tiedm100.revi  =  tiedm100.revi   
 	 endselect  	    
 	  	  	  	  	  	  	  	  	  	 |#1961467.sn   
 	 if tiedm010.prdr  =  tcyesno.no then   
 	  	 |  *  non Physical product functionality not part of standard LN   
 	  	 |  *  non Physical product migrated as physical  +  Extra Information   
 	  	 var.tiedm010.exin  =  "NON-PHYS"   
 	 else   
 	  	 var.tiedm010.exin  =  ""   
 	 endif 	  	  	  	  	  	  	  	  	 |#1961467.en 	    
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:010
:SCPAC:ti
:SCMOD:edm
:SFLNO:010
:ICOD:S
:QURY:START
select tiedm010.*     
from tiedm010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:010
:SCPAC:ti
:SCMOD:edm
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:100
:SCPAC:ti
:SCMOD:edm
:SFLNO:100
:ICOD:D
:QURY:START
	  |*  enum values of status (tiedm100.rele) have changed   
 	  if tiedm100.rele  =  tiedm.rele.yes then   
 	   	  var.tiedm100.rele  =  4 |*  approved for production   
 	   	  if tiedm100.orno  >  0 then   
 	   	   	  select  	  tiedm310.osta   
 	   	   	  from  	  tiedm310   
 	   	   	  where  	  tiedm310._index1  =  {:tiedm100.orno}   
 	   	   	  and  	  tiedm310.osta in (tiedm.osta.approved, tiedm.osta.processed.edm)   
 	   	   	  selectdo   
 	   	   	   	  var.tiedm100.rele  =  target(tiedm.osta.app.for.engg)   
 	   	   	  endselect   
 	   	  endif   
 	  endif   
 	  if tiedm100.rele  =  tiedm.rele.no then   
 	   	  var.tiedm100.rele  =  1 |*  in design   
 	  endif   
 	  if tiedm100.rele  =  tiedm.rele.cancelled then   
 	   	  var.tiedm100.rele  =  5 |*  Cancelled   
 	  endif   
 	  |*  fill engineer   
 	  var.tiedm100.engi  =  tiedm100.engi   
 |  	  if isspace(var.tiedm100.engi) then  	   	   	  |# 1474599.o   
 	  if var.tiedm100.engi  =  0 then  	   	   	  |# 1474599.n   
 	   	  var.tiedm100.engi  =  tiedm010.engi   
 	  endif   
 	   	   	   	   	   	   	   	  |# 1109375.sn   
 	  if double.cmp(tiedm010.unom, 0.0, 0.0001)  =  0 then   
 	   	  |# Bom quantity cannot be 0 in LN. If tiedm010.unom is 0   
 	   	  |# then the Bom quantity will be set to 1   
 	   	  |# follows the same rules for tiipd002.unom   
 	   	  var.tiedm100.unom  =  1   
 	  else   
 	   	  var.tiedm100.unom  =  tiedm010.unom   
 	  endif   
 	   	   	   	   	   	   	  |# 1109375.en   
 |*  determine inventory unit 	  	  	  	  	 |#2044294.sn   
 	 var.tiedm100.cuni  =  ""   
 	 select tiedm101.cprj, tiedm101.item   
 	 from tiedm101   
 	 where tiedm101._index2  =  {:tiedm100.eitm, :tiedm100.revi}   
 	 selectdo   
 	  	 if isspace(tiedm101.cprj)   
 	  	 then   
 	  	  	 select tiitm001.item   
 	  	  	 from tiitm001   
 	  	  	 where tiitm001._index1  =  {:tiedm101.item}   
 	  	  	 and tiitm001.itmt  =  tppdm.itmt.item   
 	  	  	 and tiitm001.kltc  =  tckltc.unit   
 	  	  	 as set with 1 rows   
 	  	  	 selectdo   
 	  	  	  	 var.tiedm100.cuni 	   =   	    
 	  	  	  	  	 get.new.inventory.unit.for.serialized.item(   
 	  	  	  	  	  	  	 "",   
 	  	  	  	  	  	  	 tiitm001.item)   
 	  	  	 endselect   
 	  	 else   
 	    
 	  	  	 select tipcs021.cuni   
 	  	  	 from tipcs021   
 	  	  	 where tipcs021._index1  =  {:tiedm101.cprj,   
 	  	  	  	  	  	  :tiedm101.item }   
 	  	  	 and tipcs021.kltc  =  tckltc.unit   
 	  	  	 as set with 1 rows   
 	  	  	 selectdo   
 	  	  	  	 var.tiedm100.cuni  =   	    
 	  	  	  	  	 get.new.inventory.unit.for.serialized.item(   
 	  	  	  	  	  	  	 tipcs021.cprj,   
 	  	  	  	  	  	  	 tipcs021.item)   
 	  	  	 endselect   
 	  	    
 	  	 endif   
 	  	 if not isspace(var.tiedm100.cuni)   
 	  	 then   
 	  	  	 |*  stop if a unit is found for serialized item,   
 	  	  	 |*  else continue   
 	  	  	 break   
 	  	 endif   
 	 endselect   
 	 if isspace(var.tiedm100.cuni) then   
 	  	 |*  no inventory unit found in tipcs021 and tiitm001   
 	  	 var.tiedm100.cuni  =  tiedm010.cuni   
 	 endif 	  	  	  	  	  	  	 |#2044294.en   
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:100
:SCPAC:ti
:SCMOD:edm
:SFLNO:100
:ICOD:S
:QURY:START
select tiedm100.*  , tiedm010.*     
from 	  tiedm100
where 	  tiedm010.eitm  >  ""  	  |*   for performance    
 and  	  tiedm100.eitm  =  tiedm010.eitm
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:100
:SCPAC:ti
:SCMOD:edm
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:110
:SCPAC:ti
:SCMOD:edm
:SFLNO:110
:ICOD:D
:QURY:START
	  	  	  	 |#10.5.1.sn   
 	 if tiedm110.leng  >  0.0001 or tiedm110.widt  >  0.00001 then   
 	  	 var.tiedm110.sizu  =  tibom000.buom   
 	 else   
 	  	 var.tiedm110.sizu  =  "" 	  	   
 	 endif 	  	  	  	   
 	  	  	  	 |#10.5.1.en   
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:120
:SCPAC:ti
:SCMOD:edm
:SFLNO:120
:ICOD:D
:QURY:START
	  	  	  	  	 |#10.5.1.sn   
 	 if tiedm120.leng  >  0.0001 or tiedm120.widt  >  0.00001 then   
 	  	 var.tiedm120.sizu  =  tibom000.buom   
 	 else   
 	  	 var.tiedm120.sizu  =  "" 	  	   
 	 endif 	  	  	  	   
 	  	  	  	 |#10.5.1.en   
 	 var.cprj  =  get.ti.project(tiedm120.cprj)   
 	 if (tiedm120.cpmt  =  tiedm.cpmt.copy.eitm.cust) then   
 	  	 var.tiedm120.cpmt  =  2 |  *  e  -  item to item   
 	 else 	    
 	  	 var.tiedm120.cpmt  =  etol(tiedm120.cpmt)   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:120
:SCPAC:ti
:SCMOD:edm
:SFLNO:120
:ICOD:S
:QURY:START
select tiedm120.*    
from tiedm120
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:120
:SCPAC:ti
:SCMOD:edm
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:edm
:TFLNO:320
:SCPAC:ti
:SCMOD:edm
:SFLNO:320
:ICOD:D
:QURY:START
	 	 	 	 |#10.5.1.sn  
 	 if tiedm320.leng  >  0.0001 or tiedm320.widt  >  0.00001 then  
 	 	 var.tiedm320.sizu  =  tibom000.buom  
 	 else  
 	 	 var.tiedm320.sizu  =  "" 	 	  
 	 endif 	 	 	 	  
 	 	 	 	 |#10.5.1.en  
 	 dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:grt
:TFLNO:099
:SCPAC:ti
:SCMOD:grt
:SFLNO:099
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:grt
:TFLNO:099
:SCPAC:ti
:SCMOD:grt
:SFLNO:099
:ICOD:S
:QURY:START
select 	 tigrt099.*    
from 	 tigrt099
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:grt
:TFLNO:099
:SCPAC:ti
:SCMOD:grt
:SFLNO:099
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcf
:TFLNO:500
:SCPAC:ti
:SCMOD:pcf
:SFLNO:500
:ICOD:D
:QURY:START
	  var.tipcf500.cpva  =  bcsti001.cpvl   
 	  if isspace(tipcf500.cuno) then   
 	    	  var.tipcf500.cuno  =  empty()   
 	  else   
 	    	   |   *  Convert customer to business partner.   
 	    	  return.value  =  get.business.partner(   
 	    	    	  tipcf500.cuno,   
 	    	    	  bcstc.orgn.cuno,   
 	    	    	  error.message)   
 	    	  var.tipcf500.cuno  =  bcstc008.bpid   
 	  endif   
 	   |   *  Convert reference order. Depends on reference type. Budgets   
 	   |   *  are handled differently, see below.   
 	  on case tipcf500.reft   
 	  case tcreft.sls.quotation:   
 	    	  var.tipcf500.refo  =  convert.number(bcckon.sls.quot,   
 	    	    	    	    	    	  lval(tipcf500.refo))   
 	    	  break   
 	  case tcreft.sls.order:   
 	    	  var.tipcf500.refo  =  convert.number(bcckon.act.sls,   
 	    	    	    	    	    	  lval(tipcf500.refo))   
 	    	  break   
 	  case tcreft.project:   
 	    	  var.tipcf500.refo  =  get.ti.project(tipcf500.refo)   
 	    	  break   
 	  case tcreft.budget:   
 	    	   |   *  Budgets are handled differently below.   
 	  case tcreft.standard:   
 	  default:   
 	    	  var.tipcf500.refo  =  empty()   
 	    	  break   
 	  endcase   
 	  if tipcf500.reft  <>  tcreft.budget then   
 	    	   |   *  One new product variant.   
 	    	  dump 1   
 | # 800  -  140711.sn   
 	    	   |   *  In case standard variants are used on calculation   
 	    	   |   *  parts, more records are present in bcsti002.   
 	    	  if tipcf500.reft  =  tcreft.standard then   
 |   	    	    	  select  	  bcsti002.cpva  	    	    	   | # 209069.o   
 	    	    	  select  	  bcsti002.cpvr, bcsti002.cpva  	   | # 209069.n   
 	    	    	  from  	  bcsti002   
 	    	    	  where  	  bcsti002.cpvr  =  :tipcf500.cpva   
 	    	    	   |   *  The product variant which is present in   
 	    	    	   |   *  bcsti001 has been dumped already.   
 	    	    	  and  	  bcsti002.cpva  <>  :bcsti001.cpvl   
 |   	    	    	  group by bcsti002.cpva  	    	   | # 209069.o   
 |   	    	    	  order by bcsti002.cpva  	    	    	   | # 209069.o   
 	    	    	  group by bcsti002.cpvr, bcsti002.cpva  	   | # 209069.n   
 	    	    	  order by bcsti002.cpvr, bcsti002.cpva | # 209069.n   
 	    	    	  selectdo   
 	    	    	    	  var.tipcf500.cpva  =  bcsti002.cpva   
 	    	    	    	  dump 1   
 	    	    	  endselect   
 	    	  endif   
 | # 800  -  140711.en   
 	  else   
 	    	   |   *  Create as many product variants as there are new   
 	    	   |   *  product variants in bcsti002 for the current product   
 	    	   |   *  variant. Records in bcsti002 always have a budget   
 	    	   |   *  calculation code, so use that always to fill var.tipcf500.refo.   
 	    	   |   *  Create one product variant when nothing found in   
 	    	   |   *  bcsti002. (May be the situation with a product variant   
 	    	   |   *  for a budget, but no calculation parts with that product   
 	    	   |   *  variant does never occur. But this does not lead to   
 	    	   |   *  errors.) Use empty budget calculation code to fill   
 	    	   |   *  var.tipcf500.refo.   
 	    	  hold.new.prod.var  =  0   
 	    	  select  	  bcsti002.bccd, bcsti002.cpva ,   
 	    	    	  bcsti002.cpvr  	    	    	    	   | # 209069.n   
 	    	  from  	  bcsti002   
 	    	  where  	  bcsti002.cpvr  =  :tipcf500.cpva   
 	    	   |   *  Multiple records with same new product variant can   
 	    	   |   *  exist, as more than one calculation part within one   
 	    	   |   *  budget can have the same product variant and they   
 	    	   |   *  should get the same new product variant.   
 	    	   |   *  But group by on bcsti002.cpva cannot be used,   
 	    	   |   *  because also other fields need to be selected from   
 	    	   |   *  bcsti002.   
 |   	    	  order by bcsti002.cpva  	    	    	    	   | # 209069.o   
 	    	  order by bcsti002.cpvr, bcsti002.cpva  	    	   | # 209069.n   
 	    	  selectdo   
 	    	    	  if hold.new.prod.var  <>  bcsti002.cpva then   
 	    	    	    	   |   *  New product variant. Dump record.   
 	    	    	    	  var.tipcf500.cpva  =  bcsti002.cpva   
 	    	    	    	  var.tipcf500.refo  =  get.budget.code(   
 	    	    	    	    	  tipcf500.refo,   
 	    	    	    	    	  bcsti002.bccd)   
 	    	    	    	  dump 1   
 	    	    	    	  hold.new.prod.var  =  bcsti002.cpva   
 	    	    	  endif   
 	    	  selectempty   
 	    	    	  var.tipcf500.cpva  =  bcsti001.cpvl   
 	    	    	  var.tipcf500.refo  =  get.budget.code(   
 	    	    	    	    	  tipcf500.refo,   
 	    	    	    	    	  "")         
 	    	    	  dump 1   
 	    	  endselect   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcf
:TFLNO:500
:SCPAC:ti
:SCMOD:pcf
:SFLNO:500
:ICOD:S
:QURY:START
select  	  tipcf500.*  , bcsti001.cpvl  
from 	  tipcf500, bcsti001   
 |   *  Mapping table for product variant should always exist.   
 |   *  So join table in query.
where 	  bcsti001.cpva  =  tipcf500.cpva
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcf
:TFLNO:500
:SCPAC:ti
:SCMOD:pcf
:SFLNO:500
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  	  	  	  	  	 |# 225811.sn   
 	 if tipcs020.bkcs  =  tcyesno.yes then   
 	  	 var.tipcs030.bkdt  =  0 	  	    
 	 else   
 	  	 if tipcs020.bkdt  =  0 then   
 	  	  	 |  *  set value book date according ERP LN logic   
 	  	  	 if tipcs020.plcd  =  tcplcd.forward then   
 	  	  	  	 var.tipcs030.bkdt  =  tipcs020.sdat   
 	  	  	 else   
 	  	  	  	 var.tipcs030.bkdt  =  tipcs020.ddat   
 	  	  	 endif   
 	  	 else   
 	  	  	 var.tipcs030.bkdt  =  tipcs020.bkdt   
 	  	 endif   
 	 endif   
 	  	  	  	  	  	 |# 225811.en   
 	  	  	  	  	  	    
 	 dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:400
:SCPAC:ti
:SCMOD:pcs
:SFLNO:400
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:400
:SCPAC:ti
:SCMOD:pcs
:SFLNO:400
:ICOD:S
:QURY:START
select tipcs400.*   
from tipcs400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:400
:SCPAC:ti
:SCMOD:pcs
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:450
:SCPAC:ti
:SCMOD:pcs
:SFLNO:450
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:450
:SCPAC:ti
:SCMOD:pcs
:SFLNO:450
:ICOD:S
:QURY:START
select tipcs450.*   
from tipcs450
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:450
:SCPAC:ti
:SCMOD:pcs
:SFLNO:450
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:001
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:D
:QURY:START
	  if isspace(tirou001.suno) then  	   	   	   	   	  |# 241014.sn   
 	   	  var.tirou001.bpid  =  ""    
 	  else  	   	   	   	   	   	   	   	  |# 241014.en   
 	   	  get.business.partner(tirou001.suno, bcstc.orgn.suno,error.message)   
 	   	  var.tirou001.bpid  =  bcstc008.bpid   
 	  endif  	   	   	   	   	   	   	   	  |# 241014.n  	     
 	   	   	   	   	   	   	   	   	  |# 226712.sn   
 	  |# The waittime(workingdays) is mapped to the move time (hours)in LN   
 	  |# When the wait time is transferred to hours the nr of working hours   
 	  |# per day needs to be considered.   
 	  |# example:   
 	  |# wait time BIV  =  1.5 days   
 	  |# If the working hours per day  =  8 then the Move time  =  12 hours in LN   
 	  |# If the working hours per day  =  24 then the Move time  =  36 hours in LN   
 	  |# The working hours per day is defined by the bcsbp000 parameters.   
 	   	   	   	   	   	   	   	  |# 228320.sn   
 	  if (round((1000  *  tirou001.wttm), 0, 0)  \  1000)  =  0 then   
 	  |# If in BIV the waittime is a whole number, then in LN the Move Time will be in days   
 	   	  var.tirou001.mvtm  =  round(tirou001.wttm, 0,0)   
 	   	  var.tirou001.tuni  =  target(tctope.days)   
 	  else   
 	   	  var.tirou001.tuni  =  target(tctope.hours)  	  |# 228320.en   
 	   	  var.tirou001.mvtm  =  round(tirou001.wttm  *  workhours.per.day, 2,1)  	  |# 226712.en   
 	  endif  	   	   	   	   	   	   	  |# 228320.n   
 	  var.tirou001.pddp  =   	 get.default.production.department() 	  	 |#1843068.n   
 	  	  	  	  	  	  	  	  	  	 |#10.5.1.sn   
 	 if bcint.dll0000.work.center.is.calculation.office(tirou001.cwoc) then   
 	  	 var.tirou001.kowc  =  target(tckowc.cost)   
 	  	 var.tirou001.usco  =  target(tcyesno.yes)   
 	  	 tirou001.wcru  =  0.0   
 	  	 tirou001.dcru  =  0.0   
 	 else   
 	  	 var.tirou001.kowc  =  etol(tirou001.kowc)   
 	  	 var.tirou001.usco  =  target(tcyesno.no)   
 	 endif   
 	  	  	  	  	  	  	  	  	  	 |#10.5.1.en   
 	  dump 1  	   	  |# tirou001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:001
:SCPAC:ti
:SCMOD:rou
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:002
:SCPAC:ti
:SCMOD:rou
:SFLNO:002
:ICOD:D
:QURY:START
	 for element  =  1 to 3   
 	  	 var.tirou002.mcrt(element)  =  fill.mc.field.double(   
 	  	  	  	 tirou002.mcrt,   
 	  	  	  	 element,   
 	  	  	  	 0.0) 	  	   
 	 endfor   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:002
:SCPAC:ti
:SCMOD:rou
:SFLNO:002
:ICOD:S
:QURY:START
select tirou002.*   
from tirou002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:002
:SCPAC:ti
:SCMOD:rou
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:200
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:D
:QURY:START
	 dump 1 |  *  to tirou200
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:200
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:S
:QURY:START
select bcstc018.*  , bcstc000.*     
from bcstc018, bcstc000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:rou
:TFLNO:200
:SCPAC:bc
:SCMOD:stc
:SFLNO:018
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  as set with 1 rows 	  	  	  	  	  	  	 |#1948789.n   
 	  selectdo   
 	   	  var.tisfc000.aort  =  etol(tihra000.aort)   
 	   	  var.tisfc000.ocow  =  etol(tihra000.ocow)   
 | 	   	  var.tisfc000.ckow  =  tihra000.hrwb  	  	  	  	 |#1948789.o 	  	    
 	   	  ret  =  get.labor.type( 	 bcsbp.orig.ti, 	  	  	  	 |#1948789.sn   
 	  	  	  	  	 tihra000.hrwb,   
 	  	  	  	  	 dummy.err.mess)   
 	  	  if ret  =  0 then   
 	  	  	 var.tisfc000.ckow  =  bcsbp002.nhlt   
 	  	  endif 	   	   	   	  	  	  	  	 |#1948789.en   
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:sfc
:TFLNO:000
:SCPAC:ti
:SCMOD:sfc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:sfc
:TFLNO:001
:SCPAC:ti
:SCMOD:sfc
:SFLNO:001
:ICOD:D
:QURY:START
| 	  	  	  	  	  	  	  	 |#BZ.so   
 | 	  var.tisfc001.osta  =  sfc.order.status(tisfc001.pdno, tisfc001.cprj, tisfc001.osta)   
 | 	  	  	  	  	  	  	  	 |#BZ.eo   
 	  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  	     
 	   	   	   	   	   	   	   	  |# 224115.sn   
 	   	  |*  Closed or Archived orders are always set to Definitif Closed.   
 	   	  var.tisfc001.defc  =  tcyesno.yes   
 	   	   	   	   	   	   	   	  |# 224115.en   
 	   	   	   	   	   	   	   	  |# 224115.so   
 |  	   	  |*  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  	   	   	   	   	   	   	  |# 224115.eo   
 	  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   
 	   	   	   	   	   	   	  |# FP10.sn   
 	  var.tisfc001.rwtp  =  target(tisfc.rwtp.not.appl)   
 	  if tisfc001.rwko  =  tcyesno.yes then  	   	     
 	   	  var.tisfc001.rwtp  =  target(tisfc.rwtp.manual)   
 	  endif  	   	   	   	   	     
 	   	   	   	   	   	   	  |# FP10.en   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:trp
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:000
:ICOD:S
:QURY:START
select tcmcs000.*    
from tcmcs000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:trp
:TFLNO:000
:SCPAC:tc
:SCMOD:mcs
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ctm
:TFLNO:100
:SCPAC:bc
:SCMOD:stp
:SFLNO:004
:ICOD:D
:QURY:START
	  if tppdm740.cprj  <>  hold.cprj then   
 	   	  hold.cprj  =  tppdm740.cprj   
 	  else   
 	   	  continue   
 	  endif   
 	  if isspace(tppdm740.cuno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  get.business.partner(   
 	   	   	   	  tppdm740.cuno,   
 	   	   	   	  bcstc.orgn.cuno,   
 	   	   	   	  err.mess)   
 	  endif   
 	  var.tpctm100.ofad  =  get.customer.address(tppdm740.cuno)   
 	  get.contract.status(   
 	   	   	   	  tppdm600.psts,   
 	   	   	   	  var.tpctm100.csts)   
 	  get.contract.type(   
 	   	   	   	  tppdm600.agty,   
 	   	   	   	  var.tpctm100.ctyp)   
 	  get.adv.payment.request(   
 	   	   	   	  tppdm600.cprj,   
 	   	   	   	  var.tpctm100.advn)   
 	  if tppdm600.stdt  <>  0 then   
 	   	  var.tpctm100.rdat  =  utc (tppdm600.stdt,0)   
 	  else   
 	   	  var.tpctm100.rdat  =  utc (date.num () ,0)   
 	  endif   
 	  get.enterprise.unit(tppdm600.ncmp, ext.lng.comp, err.mess)   
 	  if tppdm740.ccur  =  comp.ccur then   
 	   	  var.tpctm100.copr  =  tppdm740.copr   
 	   	  var.tpctm100.rate  =  1   
 	   	  var.tpctm100.ratf  =  1   
 	  else   
 	   	  if tppdm740.rate  =  0 or tppdm740.ratf  =  0 then   
 	   	   	  read.tcmcs008(tppdm740.ccur,   
 	   	   	   	   	  date.num(),   
 	   	   	   	   	  2,   
 	   	   	   	   	  tppdm740.rate,   
 	   	   	   	   	  tppdm740.ratf)   
 	   	  endif   
 	   	  var.tpctm100.copr  =  (tppdm740.copr  *  tppdm740.ratf)  /     
 	   	   	   	   	  tppdm740.rate   
 	   	  var.tpctm100.rate  =  tppdm740.rate   
 	   	  var.tpctm100.ratf  =  tppdm740.ratf   
 	  endif   
 |  	  if tppdm600.invm  =  tppdm.invm.prime.cost or   
 |  	  tppdm600.invm  =  tppdm.invm.unit.rate then   
 |  	   	  var.tpctm100.tins  =  10 |   *  (tppdm.tins.na)   
 |  	  else   
 |  	   	  var.tpctm100.tins  =  etol(tppdm740.tins)   
 |  	  endif   
 	  get.installment.type(   
 	   	   	   	  tppdm600.invm,   
 	   	   	   	  tppdm740.tins,   
 	   	   	   	  var.tpctm100.tins)   
 	  get.customer.country(   
 	   	   	   	  tppdm740.cuno,   
 	   	   	   	  var.tpctm100.bptc)   
 	  var.tpctm100.ccty  =  ""   
 	  var.tpctm100.cvat  =  ""   
 	  get.tax.by.country.code.and.financial.company(   
 	   	   	   	  tppdm740.ccty,   
 	   	   	   	  tppdm740.cvat,   
 	   	   	   	  tppdm600.ncmp,   
 	   	   	   	  var.tpctm100.ccty,   
 	   	   	   	  var.tpctm100.cvat,   
 	   	   	   	  err.mess)   
 	  get.created.by( "", var.tpctm100.crby)   
 	  get.creation.date( 0, var.tpctm100.crdt)   
 	  var.tpctm100.itod  =  fill.tpctm100.itod(tppdm600.cprj)   
 	  var.tpctm100.guid  =  "MIG_"  &  "tpctm100_"  &  bcstp004.cntr   
 	  dump 10  	  |   *  from bcstp004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ctm
:TFLNO:100
:SCPAC:bc
:SCMOD:stp
:SFLNO:004
:ICOD:S
:QURY:START
select bcstp004.*  , tppdm600.*  , tppdm740.*     
from 	  bcstp004, tppdm600, tppdm740
where 	  tppdm600.cprj  =  bcstp004.cprj   
 and  	  tppdm740.cprj  =  bcstp004.cprj
order by tppdm740.cprj, tppdm740.pcpc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ctm
:TFLNO:100
:SCPAC:bc
:SCMOD:stp
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ctm
:TFLNO:110
:SCPAC:tp
:SCMOD:pdm
:SFLNO:740
:ICOD:D
:QURY:START
	  if isspace(tppdm740.cuno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  get.business.partner(   
 	   	   	   	  tppdm740.cuno,   
 	   	   	   	  bcstc.orgn.cuno,   
 	   	   	   	  err.mess)   
 	  endif   
 	  var.tpctm110.ofad  =  get.customer.address(tppdm740.cuno)   
 	  get.contract.status(   
 	   	   	   	  tppdm600.psts,   
 	   	   	   	  var.tpctm110.csts)   
 	  get.contract.type(   
 	   	   	   	  tppdm600.agty,   
 	   	   	   	  var.tpctm110.ctyp)   
 	  get.adv.payment.request(   
 	   	   	   	  tppdm600.cprj,   
 	   	   	   	  var.tpctm110.advn)   
 	  if tppdm600.stdt  <>  0 then   
 	   	  var.tpctm110.rdat  =  utc (tppdm600.stdt,0)   
 	  else   
 	   	  var.tpctm110.rdat  =  utc (date.num () ,0)   
 	  endif   
 	  get.enterprise.unit(tppdm600.ncmp, ext.lng.comp, err.mess)   
 	  if tppdm740.ccur  =  comp.ccur then   
 	   	  var.tpctm110.copr  =  tppdm740.copr   
 	   	  var.tpctm110.rate  =  1   
 	   	  var.tpctm110.ratf  =  1   
 	  else   
 	   	  if tppdm740.rate  =  0 or tppdm740.ratf  =  0 then   
 	   	   	  read.tcmcs008(tppdm740.ccur,   
 	   	   	   	   	  date.num(),   
 	   	   	   	   	  2,   
 	   	   	   	   	  tppdm740.rate,   
 	   	   	   	   	  tppdm740.ratf)   
 	   	  endif   
 	   	  var.tpctm110.copr  =  (tppdm740.copr  *  tppdm740.ratf)  /     
 	   	   	   	   	  tppdm740.rate   
 	   	  var.tpctm110.rate  =  tppdm740.rate   
 	   	  var.tpctm110.ratf  =  tppdm740.ratf   
 	  endif   
 	  get.carrier.of.customer(   
 	   	   	   	  tppdm740.cuno,   
 	   	   	   	  var.tpctm110.cfrw)   
 	  get.installment.type(   
 	   	   	   	  tppdm600.invm,   
 	   	   	   	  tppdm740.tins,   
 	   	   	   	  var.tpctm110.tins)   
 	  get.customer.country(   
 	   	   	   	  tppdm740.cuno,   
 	   	   	   	  var.tpctm110.bptc)   
 	  var.tpctm110.ccty  =  ""   
 	  var.tpctm110.cvat  =  ""   
 	  get.tax.by.country.code.and.financial.company(   
 	   	   	   	  tppdm740.ccty,   
 	   	   	   	  tppdm740.cvat,   
 	   	   	   	  tppdm600.ncmp,   
 	   	   	   	  var.tpctm110.ccty,   
 	   	   	   	  var.tpctm110.cvat,   
 	   	   	   	  err.mess)   
 	  get.created.by( "", var.tpctm110.crby)   
 	  get.creation.date( 0, var.tpctm110.crdt)   
 	  var.tpctm100.itod  =  fill.tpctm100.itod(tppdm600.cprj)   
 	  var.tpctm110.guid  =  "MIGRATION_"  &  bcstp004.cntr   
 	  if tppdm600.invm  =  tppdm.invm.prime.cost then 	  	 |  *  1   
 	  	 if tppdm600.pcit  =  0.0 then   
 	  	  	 var.tpctm110.spit  =  target(tpctm.spcp.sales.price)   
 	  	 else   
 	  	  	 var.tpctm110.spit  =  target(tpctm.spcp.markup)   
 	  	 endif   
 	  	 if tppdm600.pcts  =  0.0 then   
 	  	  	 var.tpctm110.spts  =  target(tpctm.spcp.sales.price)   
 	  	 else   
 	  	  	 var.tpctm110.spts  =  target(tpctm.spcp.markup)   
 	  	 endif   
 	  	 if tppdm600.pceq  =  0.0 then   
 	  	  	 var.tpctm110.speq  =  target(tpctm.spcp.sales.price)   
 	  	 else   
 	  	  	 var.tpctm110.speq  =  target(tpctm.spcp.markup)   
 	  	 endif   
 	  	 if tppdm600.pcsb  =  0.0 then   
 	  	  	 var.tpctm110.spsb  =  target(tpctm.spcp.sales.price)   
 	  	 else   
 	  	  	 var.tpctm110.spsb  =  target(tpctm.spcp.markup)   
 	  	 endif   
 	  	 if tppdm600.pcic  =  0.0 then   
 	  	  	 var.tpctm110.spic  =  target(tpctm.spcp.sales.price)   
 	  	 else   
 	  	  	 var.tpctm110.spic  =  target(tpctm.spcp.markup)   
 	  	 endif   
 	  else   
 	  	 var.tpctm110.spit  =  15 	 |  *  target(tpctm.spcp.not.applicable) |  *  15   
 	  	 var.tpctm110.spts  =  15 	 |  *  target(tpctm.spcp.not.applicable) |  *  15   
 	  	 var.tpctm110.speq  =  15 	 |  *  target(tpctm.spcp.not.applicable) |  *  15   
 	  	 var.tpctm110.spsb  =  15 	 |  *  target(tpctm.spcp.not.applicable) |  *  15   
 	  	 var.tpctm110.spic  =  15 	 |  *  target(tpctm.spcp.not.applicable) |  *  15   
 	 endif   
 	  on case tppdm740.tins   
 	  case tppdm.tins.point:   
 	  	 var.tpctm110.tins  =  target(tpctm.intp.points)   
 	  	 break   
 	  case tppdm.tins.percent: 	  	 |  *  2   
 	  	 var.tpctm110.tins  =  target(tpctm.intp.percentage)   
 	  	 break   
 	  case tppdm.tins.fixed: 	  	 |  *  3   
 	  	 var.tpctm110.tins  =  target(tpctm.intp.amount)   
 	  	 break   
 	  default:   
 	  	 var.tpctm110.tins  =  target(tpctm.intp.not.applicable)   
 	  endcase   
 | 	  if tppdm740.tins  =  tppdm.tins.point then 	  	 |  *  1   
 | 	  	 var.tpctm110.tins  =  target(tpctm.intp.points)   
 | 	  endif   
 | 	  if tppdm740.tins  =  tppdm.tins.percent then 	  	 |  *  2   
 | 	  	 var.tpctm110.tins  =  target(tpctm.intp.percentage)   
 | 	  endif   
 | 	  if tppdm740.tins  =  tppdm.tins.fixed then 	  	 |  *  3   
 | 	  	 var.tpctm110.tins  =  target(tpctm.intp.amount)   
 | 	  endif   
 	  dump 10  	  |   *  from bcstp004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ctm
:TFLNO:110
:SCPAC:tp
:SCMOD:pdm
:SFLNO:740
:ICOD:S
:QURY:START
select  	  bcstp004.*  , tppdm600.*  , tppdm740.*     
from 	  bcstp004, tppdm600, tppdm740
where 	  bcstp004.cprj  =  tppdm600.cprj   
 and  	  bcstp004.cprj  =  tppdm740.cprj   
 and  	  bcstp004.cuno  =  tppdm740.cuno
order by bcstp004._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ctm
:TFLNO:110
:SCPAC:tp
:SCMOD:pdm
:SFLNO:740
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:000
:SCPAC:tp
:SCMOD:pdm
:SFLNO:000
:ICOD:D
:QURY:START
	  get.number.group(bcckon.tp.project,o.err.mess)   
 	  var.tppdm000.ngrp  =  bcstc002.nrgr   
 	  var.tppdm000.indt  =  utc(0,0)   
 	  var.tppdm000.dsca  =  form.text$("bcstc00035")  	    
 	  dump 1   
 	  get.number.group(bcckon.tp.project,o.err.mess)   
 	  var.tppdm000.ngrp  =  bcstc002.nrgr   
 	  var.tppdm000.indt  =  utc(date.num(),time.num())   
 	  var.tppdm000.dsca  =  form.text$("bcstc00036")   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:025
:SCPAC:tp
:SCMOD:pdm
:SFLNO:025
:ICOD:D
:QURY:START
	    	    	    	    	    	    	    	   | # 241263.so   
 | get.cost.components (bcorig.tppdm,"", tppdm025.ccco, var.o.errmess)   
 |   	  get.business.partner(tppdm025.suno,bcstc.orgn.suno, var.o.errmess)   
 	    	    	    	    	    	    	    	   | # 241263.eo   
 	  if isspace(tppdm025.ccco) then  	    	    	    	   | # 241263.sn   
 	    	  bcstc006.cost  =  ""    
 	  else   
 	    	  get.cost.components(bcorig.tppdm,"", tppdm025.ccco, var.o.errmess)   
 	  endif  	    	    	    	    	    	    	   | # 241263.en   
 	  if isspace(tppdm025.suno) then  	    	    	    	   | # 241263.sn   
 	    	  bcstc008.bpid  =  ""    
 	  else   
 	    	  get.business.partner(tppdm025.suno,bcstc.orgn.suno, var.o.errmess)   
 	  endif  	    	    	    	    	    	    	   | # 241263.en   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:025
:SCPAC:tp
:SCMOD:pdm
:SFLNO:025
:ICOD:S
:QURY:START
select  	  tppdm025.*   
from tppdm025
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:025
:SCPAC:tp
:SCMOD:pdm
:SFLNO:025
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:035
:SCPAC:tp
:SCMOD:pdm
:SFLNO:035
:ICOD:D
:QURY:START
|get.cost.components (bcorig.tppdm,"", tppdm035.ccco, var.o.errmess) |# 241263.o   
 | 	 get.business.partner(tppdm035.suno, bcstc.orgn.suno, var.o.errmess) |# 241263.o   
 	 if isspace(tppdm035.ccco) then 	  	  	  	 |# 241263.sn   
 	  	 bcstc006.cost  =  ""    
 	 else   
 	  	 get.cost.components(bcorig.tppdm,"", tppdm035.ccco, var.o.errmess)   
 	 endif 	  	  	  	  	  	  	 |# 241263.en   
 	 if isspace(tppdm035.suno) then 	  	  	  	 |# 241263.sn   
 	  	 bcstc008.bpid  =  ""    
 	 else   
 	  	 get.business.partner(tppdm035.suno, bcstc.orgn.suno, var.o.errmess)   
 	 endif 	  	  	  	  	  	  	 |# 241263.en   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:035
:SCPAC:tp
:SCMOD:pdm
:SFLNO:035
:ICOD:S
:QURY:START
select 	 tppdm035.*    
from tppdm035
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:035
:SCPAC:tp
:SCMOD:pdm
:SFLNO:035
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:090
:ICOD:D
:QURY:START
if tppdm090.prin  =  tppdm.prin.no and   
 	 tppdm090.cspt  =  tpptc.cspt.indirect then   
 	  	 var.tppdm090.cspt  =  3 | Not applicable   
 	 else   
 	  	 var.tppdm090.cspt  =  etol(tppdm090.cspt)   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:090
:ICOD:S
:QURY:START
select 	 tppdm090.*   
from tppdm090
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:090
:SCPAC:tp
:SCMOD:pdm
:SFLNO:090
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:600
:SCPAC:tp
:SCMOD:pdm
:SFLNO:600
:ICOD:D
:QURY:START
	  var.tppdm600.cprj  =  get.tp.project(tppdm600.cprj)   
 	  if itppdm0122.read.pdm601.activity.levels(tppdm600.cprj) then   
 	   	  var.tppdm600.cpla  =  tppdm600.cpla   
 	   	  var.tppdm600.rsac  =  tppdm600.rsac   
 	  else   
 	   	  var.tppdm600.cpla  =  ""   
 	   	  var.tppdm600.rsac  =  ""   
 	  endif   
 	  if not get.addresses ("tppdm600",tppdm600.cprj,o.err.mess) then   
 	  else   
 	   	  bcstc004.cadr  =  ""   
 	  endif   
 	   	  get.enterprise.unit(   
 	   	   	   	  tppdm600.ncmp,   
 	   	   	   	  get.compnr(),   
 	   	   	   	  err.mess)   
 	  if isspace(tppdm600.cbdg) then   
 	   	  var.tppdm600.pror  =  1 |   *  tppdm.pror.na   
 	  else   
 	   	  var.tppdm600.pror  =  4 |   *  tppdm.pror.estimate   
 	  endif   
 	  var.tppdm600.capp  =  2 |   *  tppdm.yeno.no   
 	  if tppdm600.cmog  =  tppdm.cmog.project then   
 	   	  if tppdm600.btco  =  tppdm.bdtp.struct.budget then   
 	   	   	  | collection by element   
 	   	   	  var.tppdm600.cmog  =  2 |   *  tppdm.cmog.structure.part   
 	   	  else   
 	   	   	  | collection by activity   
 	   	   	  var.tppdm600.cmog  =  3 |   *  tppdm.cmog.activity   
 	   	  endif   
 	  endif   
 	  if tppdm600.cmog  =  tppdm.cmog.structure.part then   
 	   	  var.tppdm600.cmog  =  2 |   *  tppdm.cmog.structure.part   
 	  endif   
 	  if tppdm600.cmog  =  tppdm.cmog.activity then   
 	   	  var.tppdm600.cmog  =  3 |   *  tppdm.cmog.activity   
 	  endif   
 	   	   	   	   	   	   	   	  |# 1061562.en   
 	  var.tppdm600.intp  =  2 |   *  tppdm.yeno.no   
 	  var.tppdm600.ipin  =  1 |   *  tppdm.yeno.yes   
 	  if etol(tppdm600.lwha)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwha  =  10 |   *  tppdm.lwha.not.used   
 	  else   
 	   	  var.tppdm600.lwha  =  etol(tppdm600.lwha)   
 	  endif   
 	  if etol(tppdm600.lwhb)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwhb  =  10 |   *  tppdm.lwha.not.used   
 	  else   
 	   	  var.tppdm600.lwhb  =  etol(tppdm600.lwhb)   
 	  endif   
 	  if etol(tppdm600.lwhc)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwhc  =  10 |   *  tppdm.lwha.not.used   
 	  else   
 	   	  var.tppdm600.lwhc  =  etol(tppdm600.lwhc)   
 	  endif   
 	  if etol(tppdm600.lwhd)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwhd  =  10 |   *  tppdm.lwha.not.used   
 	  else   
 	   	  var.tppdm600.lwhd  =  etol(tppdm600.lwhd)   
 	  endif   
 	  if etol(tppdm600.lwta)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwta  =  10 |   *  tppdm.lwtc.not.used   
 	  else   
 	   	  var.tppdm600.lwta  =  etol(tppdm600.lwta)   
 	  endif   
 	  if etol(tppdm600.lwtb)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwtb  =  10 |   *  tppdm.lwtc.not.used   
 	  else   
 	   	  var.tppdm600.lwtb  =  etol(tppdm600.lwtb)   
 	  endif   
 	  if etol(tppdm600.lwtc)  =  0 then  	   	   	  |# 1110530.n   
 	   	  var.tppdm600.lwtc  =  10 |   *  tppdm.lwtc.not.used   
 	  else   
 	   	  var.tppdm600.lwtc  =  etol(tppdm600.lwtc)   
 	  endif   
 	  var.tppdm600.uobs  =  2 |   *  tppdm.yeno.no   
 	  var.tppdm600.guid  =  "MIG_"  &  "tppdm600_"  &  var.tppdm600.cprj   
 	  dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:625
:SCPAC:tp
:SCMOD:pdm
:SFLNO:625
:ICOD:D
:QURY:START
|  	  var.temp.tppdm625.cequ  =  string.set$(" ",6)  &  tppdm625.cequ | review.so  
 |  	  select  	  tppdm605.prit  
 |  	  from  	  tppdm605  
 |  	  where  	  tppdm605._index1  =  {:tppdm625.cprj, :var.temp.tppdm625.cequ}  
 |  	  selectdo  	   	   	   	   	   	  | review.eo  
 	   	  var.tppdm625.cpgp  =  empty.string (1;6) | review.n  
 	   	  var.tppdm625.cpgs  =  empty.string (1;6) | review.n  
 |  	   	  select  	  tiitm002.cpgp,tiitm002.cpgs  	  | review.so  
 |  	   	  from  	  tiitm002  
 |  	   	  where  	  tiitm002._index1  =  {:tppdm605.prit,:tppdm625.citg}  
 	   	   	   	   	   	   	   	  | review.eo  
 	   	   	   	   	   	   	   	  | review.sn  
 	   	  select  	  tiitm002.cpgp:var.tppdm625.cpgp,  
 	   	  	 	 tiitm002.cpgs:var.tppdm625.cpgs,  
 	   	  	 	 tiitm002.csig  
 	   	  from  	  tiitm002  
 	   	  where  	  tiitm002._index1  =  {tppdm.prit.purchased, :tppdm625.citg}  
 	   	  selectdo  
 	   	  selectempty  
 	   	   	  select  	  tcmcs024.cprg  
 	   	   	  from  	  tcmcs024  
 	   	   	  as set with 1 rows  
 	   	   	  selectdo  
 |  	   	   	   	  tiitm002.cpgp  =  tcmcs024.cprg | review.so  
 |  	   	   	   	  tiitm002.cpgs  =  tcmcs024.cprg | review.eo  
 	   	   	   	  var.tppdm625.cpgp  =  tcmcs024.cprg | review.sn  
 	   	   	   	  var.tppdm625.cpgs  =  tcmcs024.cprg | review.en  
 	   	   	  endselect  
 	   	  endselect  
 |  	  endselect  	   	   	   	   	   	  | review.o  
 	   	   	   	   	   	   	   	  |# 241263.so  
 |  	  get.cost.components (bcorig.tppdm,"", tppdm625.ccco, var.o.errmess)  
 |  	  get.business.partner(tppdm625.suno,bcstc.orgn.suno, var.o.errmess)  
 	   	   	   	   	   	   	   	  |# 241263.eo  
 	  if isspace(tppdm625.ccco) then  	   	   	   	  |# 241263.sn  
 	   	  bcstc006.cost  =  ""  
 	  else  
 	   	  get.cost.components(bcorig.tppdm,"", tppdm625.ccco, var.o.errmess)  
 	  endif  	   	   	   	   	   	   	  |# 241263.en  
 	  if isspace(tppdm625.suno) then  	   	   	   	  |# 241263.sn  
 	   	  bcstc008.bpid  =  ""  
 	  else  
 	   	  get.business.partner(tppdm625.suno,bcstc.orgn.suno, var.o.errmess)  
 	  endif  	   	   	   	   	   	   	  |# 241263.en  
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:625
:SCPAC:tp
:SCMOD:pdm
:SFLNO:625
:ICOD:S
:QURY:START
select  	  tppdm625.*   
from tppdm625
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:625
:SCPAC:tp
:SCMOD:pdm
:SFLNO:625
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:635
:SCPAC:tp
:SCMOD:pdm
:SFLNO:635
:ICOD:D
:QURY:START
| select 	 tppdm605.prit 	  	  	 | review.so   
 | 	 from 	 tppdm605   
 | 	 where 	 tppdm605._index1  =  {:tppdm635.cprj,"        "  &  :tppdm635.csub}   
 | 	 selectdo 	  	  	  	  	 | review.eo   
 	  	 var.tppdm635.cpgp  =  empty.string (1;6) | review.n   
 	  	 var.tppdm635.cpgs  =  empty.string (1;6) | review.n   
 | 	  	 select 	 tiitm002.cpgp,tiitm002.cpgs | review.so   
 | 	  	 from 	 tiitm002   
 | 	  	 where 	 tiitm002._index1  =  {:tppdm605.prit, :tppdm635.citg}   
 	  	  	  	  	  	  	  	 | review.eo   
 	  	  	  	  	  	  	  	 | review.sn   
 	  	 select 	 tiitm002.cpgp:var.tppdm635.cpgp,tiitm002.cpgs:var.tppdm635.cpgs   
 	  	 from 	 tiitm002   
 	  	 where 	 tiitm002._index1  =  {tppdm.prit.purchased, :tppdm635.citg}   
 	  	 selectdo   
 	  	 selectempty   
 	  	  	 select tcmcs024.cprg   
 	  	  	 from tcmcs024   
 	  	  	 as set with 1 rows   
 	  	  	 selectdo   
 | 	  	  	  	 tiitm002.cpgp  =  tcmcs024.cprg | review.so   
 | 	  	  	  	 tiitm002.cpgs  =  tcmcs024.cprg | review.eo   
 	  	  	  	 var.tppdm635.cpgp  =  tcmcs024.cprg | review.sn   
 	  	  	  	 var.tppdm635.cpgs  =  tcmcs024.cprg | review.en   
 	  	  	 endselect   
 	  	 endselect   
 | 	 endselect 	  	  	  	 | review.o   
 	 get.cost.components (bcorig.tppdm,"", tppdm635.ccco, var.o.errmess)   
 	 get.business.partner(tppdm635.suno,bcstc.orgn.suno, var.o.errmess)   
 	 if isspace(tppdm635.ccco) then 	  	  	  	 |# 241263.sn   
 	  	 bcstc006.cost  =  ""    
 	 else   
 	  	 get.cost.components(bcorig.tppdm,"", tppdm635.ccco, var.o.errmess)   
 	 endif   
 	 if isspace(tppdm635.ccco) then   
 	  	 bcstc008.bpid  =  ""    
 	 else   
 	  	 get.business.partner(tppdm635.suno,bcstc.orgn.suno, var.o.errmess)   
 	 endif 	  	  	  	  	  	  	 |# 241263.en   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:635
:SCPAC:tp
:SCMOD:pdm
:SFLNO:635
:ICOD:S
:QURY:START
select 	 tppdm635.*    
from tppdm635
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pdm
:TFLNO:635
:SCPAC:tp
:SCMOD:pdm
:SFLNO:635
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  activity.is.milestone(tppin010.cprj,tppin010.cpla,tppin010.cact) then   
 	    	  var.tppin010.cact  =  tppdm600.rsac   
 	  else   
 	    	  var.tppin010.cact  =  tppin010.cact   
 	  endif   
 	  if var.tppin010.trsl  =  1 then   
 	    	  var.tppin010.invo  =  1   
 	  endif   
 	  var.tppin010.ccty  =  get.country.of.financial.company(tppdm600.ncmp)   
 	  var1.tppin010.ccty  =  ""   	     	     	     	     	     	    | #  210859.sn   
 	  var1.tppin010.cvat  =  ""   
 	  get.tax.by.country.code.and.financial.company(   
 	    	    	  var.tppin010.ccty,   
 	    	    	  var.tppin010.cvat,   
 	    	    	  tppdm600.ncmp,   
 	    	    	  var1.tppin010.ccty,   
 	    	    	  var1.tppin010.cvat,   
 	    	    	  err.mess)   
 	  get.contract.line.via.project.customer(   
 	    	    	  tppin010.cprj,   
 	    	    	  tppin010.cuno,   
 	    	    	  var.tppin010.cono,   
 	    	    	  var.tppin010.cnln)   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	   	  if isspace(tppin010.cuno) then   
 	   	   	  bcstc008.bpid  =  ""   
 	   	  else   
 	   	   	  dummy.long  =  get.business.partner(   
 	   	   	   	   	  tppin010.cuno,   
 	   	   	   	   	  bcstc.orgn.cuno,   
 	   	   	   	   	  err.mess)   
 	   	  endif   
 	   	  var.tppin011.ityp  =  " "   
 	   	  var.tppin011.idoc  =  0   
 	   	  var.tppin011.fcmp  =  0   
 	   	  get.contract.line.via.project.customer(   
 	   	   	  tppin010.cprj,   
 	   	   	  tppin010.cuno,   
 	   	   	  var.tppin011.cono,   
 	   	   	  var.tppin011.cnln)   
 	   	  if set.settled.invoice.lines() then   
 	   	   	  dump 1   
 	   	  endif   
 	  endif
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pin
:TFLNO:030
:SCPAC:tp
:SCMOD:pin
:SFLNO:030
:ICOD:D
:QURY:START
	  if isspace(tppin030.cuno) then   
 	    	  bcstc008.bpid  =  ""   
 	  else   
 	    	  get.business.partner(tppin030.cuno,bcstc.orgn.cuno,err.mess)   
 	  endif   
 	  get.contract.line.via.project.customer(   
 	    	    	  tppin030.cprj,   
 	    	    	  tppin030.cuno,   
 	    	    	  var.tppin030.cono,   
 	    	    	  var.tppin030.cnln)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pin
:TFLNO:030
:SCPAC:tp
:SCMOD:pin
:SFLNO:030
:ICOD:S
:QURY:START
select tppin030.*   
from tppin030
where tppin030.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pin
:TFLNO:030
:SCPAC:tp
:SCMOD:pin
:SFLNO:030
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:000
:SCPAC:tp
:SCMOD:ppc
:SFLNO:000
:ICOD:D
:QURY:START
	  var.tpppc000.indt  =  utc(0, 0)   
 	  var.tpppc000.dsca  =  form.text$("bcstc00035")   
 	   	  |   *  "Actual Set"     
 	  Dump 1   
 	  var.tpppc000.indt  =  utc(date.num(), time.num())   
 	  var.tpppc000.dsca  =  form.text$("bcstc00036")   
 	  |   *  "Converted from Baan IV"     
 	     
 	  Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:000
:SCPAC:tp
:SCMOD:ppc
:SFLNO:000
:ICOD:S
:QURY:START
select tpppc000.*     
from tpppc000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:000
:SCPAC:tp
:SCMOD:ppc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:150
:SCPAC:tp
:SCMOD:ppc
:SFLNO:150
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:150
:SCPAC:tp
:SCMOD:ppc
:SFLNO:150
:ICOD:S
:QURY:START
select tpppc150.*   
from tpppc150
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:150
:SCPAC:tp
:SCMOD:ppc
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:160
:SCPAC:tp
:SCMOD:ppc
:SFLNO:160
:ICOD:D
:QURY:START
dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:160
:SCPAC:tp
:SCMOD:ppc
:SFLNO:160
:ICOD:S
:QURY:START
select tpppc160.*   
from tpppc160
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:160
:SCPAC:tp
:SCMOD:ppc
:SFLNO:160
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:215
:ICOD:D
:QURY:START
	  var.tpppc200.cprj  =  get.tp.project(tpppc215.cprj)   
 	  var.tpppc215.item  =  ""   
 	  var.tppdm.reft.item.type  =  read.item (   
 	   	   	   	   	  tpppc215.item,   
 	   	   	   	   	  tpppc215.cprj,   
 	   	   	   	   	  var.tppdm.desc.descr,2,0,1)   
 	  if (var.tppdm.reft.item.type  =  tppdm.reft.project) then   
 	   	  if get.customised.item.linked.to.project(   
 	   	   	   	   	  tpppc215.cprj,   
 	   	   	   	   	  tpppc215.item,   
 	   	   	   	   	  o.cust.project,   
 	   	   	   	   	  o.cust.item) then   
 	   	   	  var.cust.project  =  get.ti.project(o.cust.project)   
 	   	   	  var.tpppc215.item  =  segment.item.code (   
 	   	   	   	   	  o.cust.item,   
 	   	   	   	   	  var.cust.project)   
 	   	  else   
 	   	   	  var.tpppc215.item  =  segment.item.code (   
 	   	   	   	   	  tpppc215.item,   
 	   	   	   	   	  var.tpppc200.cprj)   
 	   	  endif   
 	  else   
 	   	  if (var.tppdm.reft.item.type  =  tppdm.reft.standard) then   
 	   	   	  temp.cprj  =  ""   
 	   	   	  var.tpppc215.item  =  segment.item.code (   
 	   	   	   	   	  tpppc215.item,   
 	   	   	   	   	  temp.cprj)   
 	   	  endif   
 	  endif   
 	  ret.val  =  get.contract.line.via.peg(  	   	   	   	  |# WG.sn   
 	   	   	  tpppc215.cprj,   
 	   	   	  tpppc215.cspa,   
 	   	   	  tpppc215.cact,   
 	   	   	  tpppc215.cstl,   
 	   	   	  var.tpppc200.cono,   
 	   	   	  var.tpppc200.cnln,   
 	   	   	   	  o.err.mess)   
 	  if ret.val  <>  0 then   
 	   	  log.error.data(o.err.mess)   
 	  endif  	   	   	   	   	   	   	   	  |# WG.en   
 	  if (tpppc215.ninv  =  0) then   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.no   
 	  else   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.yes   
 	  endif   
 	  if isspace(tpppc215.ccco) then   
 	   	  var.tpppc200.ccco  =  ""   
 	  else   
 	   	  dummy.long  =  get.cost.components(   
 	   	   	   	  bcorig.tppdm,   
 	   	   	   	  "",   
 	   	   	   	  tpppc215.ccco,   
 	   	   	   	  o.err.mess)   
 	   	  var.tpppc200.ccco  =  bcstc006.cost   
 	  endif   
 	  if tpppc215.invo  =  tppdm.yeno.yes then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	  else   
 	   	  determine.default.value.for.var.tpppc200.blbl(   
 	   	   	   	  tpppc215.cprj,   
 	   	   	   	  tpppc215.cstl)   
 	  endif   
 	  var.tpppc200.srni  =  tpppc215.srni   
 	  var.tpppc200.ftty  =  ""   
 	  var.tpppc200.fdoc  =  0   
 |   ************  Copied from tpppc215 IV  --  FP7  ******************  sn   
 	  if tpppc215.tetd  =  tpppc.tetd.expect and   
 	   	  tpppc215.srnb  <>  0 then   
 	   	  select tdpur041.oqua   
 	   	  from  	  tdpur041   
 	   	  where  	  tdpur041._index1  =  {:tpppc215.orno, :tpppc215.pono}   
 	   	  and  	  tdpur041.oqua  <>  0   
 	   	  selectdo   
 	   	   	  zero.quantity  =  false   
 	   	   	  if tdpur041.oqua  >  0 then   
 	   	   	   	  positive.quan  =  true   
 	   	   	  else   
 	   	   	   	  positive.quan  =  false   
 	   	   	  endif   
 	   	  selectempty   
 	   	   	  zero.quantity  =  true   
 	   	   	  positive.quan  =  true   
 	   	  endselect   
 	   	  if not zero.quantity then   
 	   	   	  if positive.quan then   
 	   	   	   	  if tpppc215.quan  <  0 then   
 	   	   	   	   	  var.tpppc200.comf  =   0 |   *  empty   
 	   	   	   	  else   
 	   	   	   	   	  var.tpppc200.comf  =  etol(tpppc215.comf)   
 	   	   	   	  endif   
 	   	   	  else   
 	   	   	   	  if tpppc215.quan  >  0 then   
 	   	   	   	   	  var.tpppc200.comf  =  0 |   *  empty   
 	   	   	   	  else   
 	   	   	   	   	  var.tpppc200.comf  =  etol(tpppc215.comf)   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	  else   
 	   	   	  var.tpppc200.comf  =  etol(tpppc215.comf)   
 	   	  endif   
 	  else   
 	   	  var.tpppc200.comf  =  etol(tpppc215.comf)   
 	  endif   
 	  tfacp200.pdif  =  0.0   
 	  on case tpppc215.tetd   
 	   	  case tpppc.tetd.order.invoice:   
 	   	  case tpppc.tetd.expect:   
 	   	   	   	  |   *  Commitments are logged only for POs   
 	   	   	  var.tpppc200.koor  =  etol(tckoor.act.pur)   
 	   	   	  var.bcckon.orno  =  convert.tckoor.to.bcckon(   
 	   	   	   	   	  tckoor.act.pur)   
 	   	   	  var.tpppc200.orno  =  convert.number(   
 	   	   	   	   	  var.bcckon.orno ,   
 	   	   	   	   	  tpppc215.orno)   
 	   	   	  if tpppc215.tetd  =  tpppc.tetd.order.invoice then   
 	   	   	   	  update.srni.from.tfacp200()   
 	   	   	  endif   
 	   	   	  break   
 	   	  case tpppc.tetd.stock:   
 	   	   	  var.tpppc200.koor  =  etol(tckoor.wrh.order)   
 	   	   	  var.bcckon.orno  =  convert.tckoor.to.bcckon(   
 	   	   	   	   	  tckoor.wrh.order)   
 	   	   	  var.tpppc200.orno  =  convert.number(   
 	   	   	   	   	  bcckon.repl.order ,   
 	   	   	   	   	  tpppc215.orno)   
 	   	   	  break   
 	   	  default:   
 	   	   	  var.tpppc200.koor  =  0   
 	   	   	  var.tpppc200.orno  =  ""   
 	  endcase   
 |   ************  Copied from tpppc215 IV  --  FP7  ******************  en   
 	  var.tpppc200.srnb  =  get.pur.order.line.sequence.number(tpppc215.srnb)   
 	  if isspace(tpppc215.suno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  dummy.long  =  get.business.partner(   
 	   	   	   	  tpppc215.suno,   
 	   	   	   	  bcstc.orgn.suno,   
 	   	   	   	  o.err.mess)   
 	  endif   
 	  dummy.long  =  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)   
 	  var.guid.sern  =  var.guid.sern  +  1   
 	  var.guid.sern.str  =  str$(var.guid.sern)   
 	  var.tpppc200.guid  =  "MIGMAT"  &     
 	   	   	  var.guid.sern.str  &     
 	   	   	  tpppc215.cprj   
 	  var.tpppc200.amoc  =  tpppc215.amoc   
 	  var.tpppc200.sern  =  tpppc215.sern   
 	  var.tpppc200.pric  =  tpppc215.pric   
 	  var.tpppc200.cdoc  =  tpppc215.cdoc   
 	  var.tpppc200.ncmp  =  tpppc215.ncmp   
 	  if var.tpppc200.comf  =  0 then   
 	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app   
 	  else   
 	   	  var.tpppc200.comf  =  etol(tpppc215.comf)   
 	  endif   
 	  var.tpppc200.quan  =  tpppc215.quan   
 	  var.tpppc200.amos  =  tpppc215.amos   
 	  get.post.to.finance.tpppc215(   
 	   	   	   	   	  var.tpppc215.tetd,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 	  convert.tpppc200.comf(   
 	   	   	  var.tpppc200.potf,  	  |   *  i.new.determined.potf,   
 	   	   	  etol(tpppc215.comf),  	  |   *  i.old.comf,   
 	   	   	  "tpppc215",  	   	  |   *  i.table,   
 	   	   	  var.tpppc200.comf)  	  |   *  io.new.old.comf)   
 	  fill.vat.fields(   
 	   	   	  tpppc215.cprj,   
 	   	   	  var.tpppc200.txct,   
 	   	   	  var.tpppc200.cvat)   
 	  var.tpppc200.srnb  =  get.order.line.sequence(tpppc215.srnb)   
 	  var.tpppc200.ptyc  =  fill.ptyc.from.tetd()   
 	  convert.tpppc200.koor(   
 	   	   	  var.tpppc200.koor, |   *  long i.tpppc200.koor,   
 	   	   	  tpppc215.orno,   
 	   	   	  var.tpppc200.ptyc,   
 	   	   	  "tpppc215",   
 	   	   	  var.tpppc200.koor)   
 	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	   	  var.tpppc200.curc  =  comp.ccur   
 	   	  var.tpppc200.rtcc(1)  =  1   
 	   	  var.tpppc200.rtcc(2)  =  0   
 	   	  var.tpppc200.rtcc(3)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  1   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(tpppc215.amoc, 1)   
 	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(tpppc215.amoc, 1)   
 	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	   	  var.tpppc200.rdat  =  utc(tpppc215.rgdt,0)   
 	  else   
 	   	  var.tpppc200.curc  =  ""   
 	   	  var.tpppc200.rtcc(1)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  0   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  0   
 	   	  var.tpppc200.cohd(1)  =  0   
 	   	  var.tpppc200.rtyp  =  ""   
 	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  endif   
 |  	  if cost.history.allow.invoicing(   
 |  	   	   	   	  tpppc215.cprj,   
 |  	   	   	   	  tpppc215.cstl,   
 |  	   	   	   	  tpppc215.tetd,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty)   
 	  if cost.history.allow.invoicing(   
 	   	   	   	  tpppc215.cprj,   
 	   	   	   	  tpppc215.cstl,   
 	   	   	   	  var.tpppc200.ptyc)   
 	  then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	  var.tpppc200.pris  =  tpppc215.pris   
 	   	  var.tpppc200.amos  =  tpppc215.amos   
 	   	  var.tpppc200.curs  =  comp.ccur   
 	   	  var.tpppc200.rtcs(1)  =  1   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  1   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(tpppc215.rgdt,0)   
 	   	 var.tpppc200.alin  =  tcyesno.yes   
 	  else   
 	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	  var.tpppc200.pris  =  0.0   
 	   	  var.tpppc200.amos  =  0.0   
 	   	  var.tpppc200.curs  =  ""   
 	   	  var.tpppc200.rtcs(1)  =  0   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  0   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(0,0)   
 	   	  var.tpppc200.txct  =  ""   
 	   	  var.tpppc200.cvat  =  ""   
 	   	 var.tpppc200.alin  =  tcyesno.no   
 	  endif   
 	  if isspace(tpppc215.orno) then   
 	   	  var.tpppc200.lcor  =  0   
 	  else   
 	   	  var.tpppc200.lcor  =  get.compnr()   
 	  endif   
 |  	  dump 215 |   *  from tpppc215   
 	  dump.tpppc215()   
 	  if tpppc215.tetd  =  tpppc.tetd.order.invoice then   
 	   	  if tfacp200.pdif  <>  0.0 then   
 	  	  	 get.receipt.amount.material( 	 |  *  KB1876758_5.sn   
 	  	  	  	  	 tpppc215.orno,   
 	  	  	  	  	 tpppc215.pono,   
 	  	  	  	  	 tpppc215.srnb,   
 	  	  	  	  	 receipt.amount)   
 | 	  	  	 if abs(receipt.amount)  <>  tpppc215.amoc then   
 	  	   	   	  	  	  	 |  *  KB1876758_5.en   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc215.tetd  =  target(9) |   *  tpppc.tetd.value.corr   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc215.tetd  =  target(tpppc.tetd.value.corr)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.price.variance)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc215.sern(   
 	   	   	   	   	  tpppc215.cprj,   
 	   	   	   	   	  tpppc215.cspa,   
 	   	   	   	   	  tpppc215.item)   
 	  	  	  	  	  	  	 |  *  KB1876758.so   
 | 	   	   	  var.tpppc200.amoc  =    -  1  *  tfacp200.pdif   
 	  	  	  	  	  	  	 |  *  KB1876758.eo   
 	   	   	  	  	  	  	  	 |  *  KB1876758.sn   
 	   	   	  var.tpppc200.amoc  =     
 	   	   	  	  	  	 (receipt.amount  +     
 	   	   	  	  	  	  var.tpppc200.amoc)   
 	   	   	  	  	  	  	  	 |  *  KB1876758.en   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  etol(tppdm.yeno.no)   
 	   	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc215(   
 	   	   	   	   	  var.tpppc215.tetd,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetd()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc215.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 	   	   	  dump.tpppc215()  	  |   *  Price Variance   
 	  	  	  	  	  	  	  	 |#1876758.so   
 	   	   	  var.tpppc215.tetd  =  target(10) |   *  tpppc.tetd.value.corr.rev   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc215.tetd  =  target(tpppc.tetd.value.corr.rev)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.price.var.rev)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc215.sern(   
 	   	   	   	   	  tpppc215.cprj,   
 	   	   	   	   	  tpppc215.cspa,   
 	   	   	   	   	  tpppc215.item)   
 | 	   	   	  var.tpppc200.amoc  =  tfacp200.pdif 	  |  *  KB1876758.o   
 	   	   	  var.tpppc200.amoc  =    -  1  *  var.tpppc200.amoc 	  |  *  KB1876758.n   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app   
 	   	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc215(   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	   	   	  10, |   *  tpppc.tetd.value.corr.rev   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	   	   	   	   	  var.tpppc215.tetd, 	 |#1876758.n   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetd()   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc215.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 	   	   	  dump.tpppc215()  	  |   *  Price Variance (Reverse posting)   
 | 	   	  	 endif 	  	  	  	  	 |#1876758_5.n   
 	   	  endif   
 	   	  if expense.amount  <>  0.0 then   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc215.tetd  =  target(8) |   *  tpppc.tetd.exp.tax.dir   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc215.tetd  =  target(tpppc.tetd.exp.tax.dir)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.expense.tax)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc215.sern(   
 	   	   	   	   	  tpppc215.cprj,   
 	   	   	   	   	  tpppc215.cspa,   
 	   	   	   	   	  tpppc215.item)   
 	   	   	  var.tpppc200.amoc  =  expense.amount   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  etol(tppdm.yeno.no)   
 	   	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc215(   
 	   	   	   	   	  var.tpppc215.tetd,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetd()   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc215.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 	   	   	  dump.tpppc215()  	  |   *  from tpppc215, Expense Tax   
 	   	  endif   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:215
:ICOD:S
:QURY:START
select tppdm600.ncmp, tppdm600.cprj, tpppc215.*     
from 	  tppdm600, tpppc215
where 	  tpppc215.cprj refers to tppdm600 unref skip
order by tpppc215._index1  	   	   	  |# 1626994.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:215
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:235
:ICOD:D
:QURY:START
	  var.tpppc200.cprj  =  get.tp.project(tpppc235.cprj)   
 	 var.tpppc200.coob  =  strip$(tpppc235.task) |#1876758_3.n   
 	  if isspace(tpppc235.ccco) then   
 	   	  var.tpppc200.ccco  =  ""   
 	  else   
 	   	  dummy.long  =  get.cost.components(   
 	   	   	   	  bcorig.tppdm,   
 	   	   	   	  "",   
 	   	   	   	  tpppc235.ccco,   
 	   	   	   	  o.err.mess)   
 	   	  var.tpppc200.ccco  =  bcstc006.cost   
 	  endif   
 	  ret.val  =  get.contract.line.via.peg(  	   	  |# FP10.sn   
 	   	   	  tpppc235.cprj,   
 	   	   	  tpppc235.cspa,   
 	   	   	  tpppc235.cact,   
 	   	   	  tpppc235.cstl,   
 	   	   	  var.tpppc200.cono,   
 	   	   	  var.tpppc200.cnln,   
 	   	   	   	  o.err.mess)   
 	  if ret.val  <>  0 then   
 	   	  log.error.data(o.err.mess)   
 	  endif  	   	   	   	   	   	  |# FP10.en   
 	  if (tpppc235.ninv  =  0) then   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.no   
 	  else   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.yes   
 	  endif   
 	  var.tpppc200.ptyc  =  fill.ptyc.from.tete()   
 	  convert.tpppc200.koor(   
 	   	   	  var.tpppc200.koor, |   *  long i.tpppc200.koor,   
 	   	   	  tpppc235.orno,   
 	   	   	  var.tpppc200.ptyc,   
 	   	   	  "tpppc235",   
 	   	   	  var.tpppc200.koor)   
 	  if tpppc235.invo  =  tppdm.yeno.yes then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	  else   
 	   	  determine.default.value.for.var.tpppc200.blbl(   
 	   	   	   	  tpppc235.cprj,   
 	   	   	   	  tpppc235.cstl)   
 	  endif   
 	  convert.tpppc200.comf(   
 	   	   	  var.tpppc200.potf,   
 	   	   	  etol(tpppc235.comf),   
 	   	   	  "tpppc235",   
 	   	   	  var.tpppc200.comf)   
 	  var.guid.sern  =  var.guid.sern  +  1   
 	  var.guid.sern.str  =  str$(var.guid.sern)   
 	  var.tpppc200.guid  =  "MIGLAB"  &     
 	   	   	  var.guid.sern.str  &     
 	   	   	  tpppc235.cprj   
 	  if isspace(tpppc235.suno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  dummy.long  =  get.business.partner(   
 	   	   	   	  tpppc235.suno,   
 	   	   	   	  bcstc.orgn.suno,   
 	   	   	   	  o.err.mess)   
 	  endif   
 	  dummy.long  =  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)   
 	  get.post.to.finance.tpppc235( var.tpppc200.potf)   
 	  fill.vat.fields(   
 	   	   	  tpppc235.cprj,   
 	   	   	  var.tpppc200.txct,   
 	   	   	  var.tpppc200.cvat)   
 	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	   	  var.tpppc200.curc  =  comp.ccur   
 	   	  var.tpppc200.rtcc(1)  =  1   
 	   	  var.tpppc200.rtcc(2)  =  0   
 	   	  var.tpppc200.rtcc(3)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  1   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(tpppc235.amoc, 1)   
 	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(tpppc235.amoc, 1)   
 	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	   	  var.tpppc200.rdat  =  utc(tpppc235.rgdt,0)   
 	  	  var.tpppc200.quan  =  tpppc235.quan 	  	 |#1876758_3.sn   
 	  	  var.tpppc200.pric  =  tpppc235.ratc   
 	  	  var.tpppc200.amoc  =  tpppc235.amoc 	  	 |#1876758_3.en   
 	  else   
 	   	  var.tpppc200.curc  =  ""   
 	   	  var.tpppc200.rtcc(1)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  0   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  0   
 	   	  var.tpppc200.cohd(1)  =  0   
 	   	  var.tpppc200.rtyp  =  ""   
 	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  var.tpppc200.quan  =  0.0 	  	 |#1876758_3.sn   
 	  	  var.tpppc200.pric  =  0.0   
 	  	  var.tpppc200.amoc  =  0.0 	  	 |#1876758_3.en   
 	  endif   
 |  	  if cost.history.allow.invoicing(   
 |  	   	   	   	  tpppc235.cprj,   
 |  	   	   	   	  tpppc235.cstl,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty)   
 	  if cost.history.allow.invoicing(   
 	   	   	   	  tpppc235.cprj,   
 	   	   	   	  tpppc235.cstl,   
 	   	   	   	  var.tpppc200.ptyc)   
 	  then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	  var.tpppc200.pris  =  tpppc235.rats   
 	   	  var.tpppc200.amos  =  tpppc235.amos   
 	   	  var.tpppc200.curs  =  comp.ccur   
 	   	  var.tpppc200.rtcs(1)  =  1   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  1   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(tpppc235.rgdt,0)   
 	   	  var.tpppc200.alin  =  tcyesno.yes   
 	  else   
 	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	  var.tpppc200.pris  =  0.0   
 	   	  var.tpppc200.amos  =  0.0   
 	   	  var.tpppc200.curs  =  ""   
 	   	  var.tpppc200.rtcs(1)  =  0   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  0   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(0,0)   
 	   	  var.tpppc200.txct  =  ""   
 	   	  var.tpppc200.cvat  =  ""   
 	   	 var.tpppc200.alin  =  tcyesno.no   
 	  endif   
 |  	  if isspace(tpppc235.orno) then   
 	   	  var.tpppc200.lcor  =  0   
 |  	  else   
 |  	   	  var.tpppc200.lcor  =  get.compnr()   
 |  	  endif   
 |  	  dump 235  	  |   *  from tpppc235   
 	  dump.tpppc235()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:235
:ICOD:S
:QURY:START
select  	  tppdm600.ncmp, tppdm600.cprj, tpppc235.*     
from 	  tppdm600, tpppc235
where 	  tpppc235.cprj refers to tppdm600 unref skip
order by tpppc235._index1  	   	   	  |# 1626994.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:235
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:255
:ICOD:D
:QURY:START
	  var.tpppc200.cprj  =  get.tp.project(tpppc255.cprj)   
 	  var.tpppc200.coob  =  strip$(tpppc255.cequ) |#1876758_3.n   
 	  ret.val  =  get.contract.line.via.peg(  	   	  |# FP10.sn   
 	   	   	  tpppc255.cprj,   
 	   	   	  tpppc255.cspa,   
 	   	   	  tpppc255.cact,   
 	   	   	  tpppc255.cstl,   
 	   	   	  var.tpppc200.cono,   
 	   	   	  var.tpppc200.cnln,   
 	   	   	   	  o.err.mess)   
 	  if ret.val  <>  0 then   
 	   	  log.error.data(o.err.mess)   
 	  endif  	   	   	   	  |# FP10.en   
 	  reft.csub  =  read.equipment(   
 	   	   	   	  tpppc255.cequ,   
 	   	   	   	  tpppc255.cprj,   
 	   	   	   	  desc.cequ,   
 	   	   	   	  1,0,0)   
 	  if reft.cequ  =  tppdm.reft.standard then   
 	   	  var.tpppc200.cuni   =  tppdm025.cuni   
 	  else   
 	   	  var.tpppc200.cuni   =  tppdm635.cuni   
 	  endif   
 	  if (tpppc255.ninv  =  0) then   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.no   
 	  else   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.yes   
 	  endif   
 	  if isspace(tpppc255.ccco) then   
 	   	  var.tpppc200.ccco  =  ""   
 	  else   
 	   	  dummy.long  =  get.cost.components(   
 	   	   	   	  bcorig.tppdm,   
 	   	   	   	  "",   
 	   	   	   	  tpppc255.ccco,   
 	   	   	   	  o.err.mess)   
 	   	  var.tpppc200.ccco  =  bcstc006.cost   
 	  endif   
 	  if tpppc255.invo  =  tppdm.yeno.yes then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	  else   
 	   	  determine.default.value.for.var.tpppc200.blbl(   
 	   	   	   	  tpppc255.cprj,   
 	   	   	   	  tpppc255.cstl)   
 	  endif   
 	  var.tpppc200.srni  =  tpppc255.srni   
 	  var.tpppc200.ftty  =  ""   
 	  var.tpppc200.fdoc  =  0   
 	  tfacp200.pdif  =  0.0   
 	  var.tpppc200.koor  =  etol(tckoor.act.pur)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.act.pur)   
 	  var.tpppc200.orno  =  convert.number(   
 	   	   	  var.bcckon.orno ,   
 	   	   	  tpppc255.orno)   
 	  if tpppc255.tetn  =  tpppc.tetn.order.invoice then   
 	   	  update.srni.from.tfacp200()   
 	  endif   
 	  var.tpppc200.srnb  =  get.pur.order.line.sequence.number(tpppc255.srnb)   
 	  if isspace(tpppc255.suno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  dummy.long  =  get.business.partner(   
 	   	   	   	  tpppc255.suno,   
 	   	   	   	  bcstc.orgn.suno,   
 	   	   	   	  o.err.mess)   
 	  endif   
 	  dummy.long  =  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)   
 	  var.guid.sern  =  var.guid.sern  +  1   
 	  var.guid.sern.str  =  str$(var.guid.sern)   
 	  var.tpppc200.guid  =  "MIGEQU"  &     
 	   	   	  var.guid.sern.str  &     
 	   	   	  tpppc255.cprj   
 	  var.tpppc200.amoc  =  tpppc255.amoc   
 	  var.tpppc200.sern  =  tpppc255.sern   
 	  var.tpppc200.pric  =  tpppc255.ratc   
 	  var.tpppc200.cdoc  =  tpppc255.cdoc   
 	  var.tpppc200.ncmp  =  tpppc255.ncmp   
 	  if var.tpppc200.comf  =  0 then   
 	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app   
 	  else   
 	   	  var.tpppc200.comf  =  etol(tpppc255.comf)   
 	  endif   
 	  var.tpppc200.cuti  =  tpppc255.cuti   
 	  var.tpppc200.time  =  tpppc255.time   
 	  var.tpppc200.quan  =  tpppc255.quan   
 	  var.tpppc200.amos  =  tpppc255.amos   
 	  get.post.to.finance.tpppc255(   
 	   	   	   	   	  var.tpppc255.tetn,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 	  convert.tpppc200.comf(   
 	   	   	  var.tpppc200.potf,   
 	   	   	  etol(tpppc255.comf),   
 	   	   	  "tpppc255",   
 	   	   	  var.tpppc200.comf)   
 	  fill.vat.fields(   
 	   	   	  tpppc255.cprj,   
 	   	   	  var.tpppc200.txct,   
 	   	   	  var.tpppc200.cvat)   
 	  var.tpppc200.srnb  =  get.order.line.sequence(tpppc255.srnb)   
 	  var.tpppc200.ptyc  =  fill.ptyc.from.tetn()   
 	  convert.tpppc200.koor(   
 	   	   	  var.tpppc200.koor, |   *  long i.tpppc200.koor,   
 	   	   	  tpppc255.orno,   
 	   	   	  var.tpppc200.ptyc,   
 	   	   	  "tpppc255",   
 	   	   	  var.tpppc200.koor)   
 	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	   	  var.tpppc200.curc  =  comp.ccur   
 	   	  var.tpppc200.rtcc(1)  =  1   
 	   	  var.tpppc200.rtcc(2)  =  0   
 	   	  var.tpppc200.rtcc(3)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  1   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(tpppc255.amoc, 1)   
 	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(tpppc255.amoc, 1)   
 	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	   	  var.tpppc200.rdat  =  utc(tpppc255.rgdt,0)   
 	  else   
 	   	  var.tpppc200.curc  =  ""   
 	   	  var.tpppc200.rtcc(1)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  0   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  0   
 	   	  var.tpppc200.cohd(1)  =  0   
 	   	  var.tpppc200.rtyp  =  ""   
 	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  endif   
 |  	  if cost.history.allow.invoicing(   
 |  	   	   	   	  tpppc255.cprj,   
 |  	   	   	   	  tpppc255.cstl,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  tpppc255.tetn,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty)   
 	  if cost.history.allow.invoicing(   
 	   	   	   	  tpppc255.cprj,   
 	   	   	   	  tpppc255.cstl,   
 	   	   	   	  var.tpppc200.ptyc)   
 	  then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	  var.tpppc200.pris  =  tpppc255.rats   
 	   	  var.tpppc200.amos  =  tpppc255.amos   
 	   	  var.tpppc200.curs  =  comp.ccur   
 	   	  var.tpppc200.rtcs(1)  =  1   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  1   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(tpppc255.rgdt,0)   
 	   	 var.tpppc200.alin  =  tcyesno.yes   
 	  else   
 	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	  var.tpppc200.pris  =  0.0   
 	   	  var.tpppc200.amos  =  0.0   
 	   	  var.tpppc200.curs  =  ""   
 	   	  var.tpppc200.rtcs(1)  =  0   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  0   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(0,0)   
 	   	  var.tpppc200.txct  =  ""   
 	   	  var.tpppc200.cvat  =  ""   
 	   	 var.tpppc200.alin  =  tcyesno.no   
 	  endif   
 	  if isspace(tpppc255.orno) then   
 	   	  var.tpppc200.lcor  =  0   
 	  else   
 	   	  var.tpppc200.lcor  =  get.compnr()   
 	  endif   
 |  	  dump 255 |   *  from tpppc255   
 	  dump.tpppc255()   
 	  if tpppc255.tetn  =  tpppc.tetn.order.invoice then   
 	   	  if tfacp200.pdif  <>  0.0 then   
 	  	  	 get.receipt.amount.equipment( 	 |  *  KB1876758_5.sn   
 	  	  	  	  	 tpppc255.orno,   
 	  	  	  	  	 tpppc255.pono,   
 	  	  	  	  	 tpppc255.srnb,   
 	  	  	  	  	 receipt.amount)   
 | 	  	  	 if abs(receipt.amount)  <>  tpppc255.amoc then   
 	  	   	   	  	  	  	 |  *  KB1876758_5.en   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc255.tetn  =  target(7) |   *  tpppc.tetn.value.corr   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc255.tetn  =  target(tpppc.tetn.value.corr)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.price.variance)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc255.sern(   
 	   	   	   	  tpppc255.cprj,   
 	   	   	   	  tpppc255.cspa,   
 	   	   	   	  tpppc255.cequ)   
 	  	  	  	  	  	  	 |  *  KB1876758.so   
 | 	   	   	  var.tpppc200.amoc  =    -  1  *  tfacp200.pdif   
 	  	  	  	  	  	  	 |  *  KB1876758.eo   
 	   	   	  	  	  	  	  	 |  *  KB1876758.sn   
 	   	   	  var.tpppc200.amoc  =     
 	   	   	  	  	  	 (receipt.amount  +     
 	   	   	  	  	  	  var.tpppc200.amoc)   
 	   	   	  	  	  	  	  	 |  *  KB1876758.en   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  etol(tppdm.yeno.no)   
 	   	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc255(   
 	   	   	   	   	  var.tpppc255.tetn,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetn()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc255.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 |  	   	   	  dump 255  	  |   *  Price Variance   
 	   	   	  dump.tpppc255()   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc255.tetn  =  target(8) |   *  tpppc.tetn.value.corr.rev   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc255.tetn  =  target(tpppc.tetn.value.corr.rev)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.price.var.rev)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc255.sern(   
 	   	   	   	  tpppc255.cprj,   
 	   	   	   	  tpppc255.cspa,   
 	   	   	   	  tpppc255.cequ)   
 | 	   	   	  var.tpppc200.amoc  =  tfacp200.pdif 	  |  *  KB1876758.o   
 	   	   	  var.tpppc200.amoc  =    -  1  *  var.tpppc200.amoc 	  |  *  KB1876758.n   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app   
 	   	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc255(   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	   	   	  10, |   *  tpppc.tetb.value.corr.rev   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	   	   	   	   	  var.tpppc255.tetn, 	 |#1876758.n   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetn()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc255.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 |  	   	   	  dump 255  	  |   *  Price Variance (Reverse posting)   
 	   	   	  dump.tpppc255()   
 | 	   	  	 endif 	  	  	  	  	 |#1876758_5.n   
 	   	  endif   
 	   	  if expense.amount  <>  0.0 then   
 	   	   	  var.tpppc255.tetn  =  target(6) |   *  tpppc.tetn.exp.tax.dir   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc255.tetn  =  target(6) |   *  tpppc.tetn.exp.tax.dir   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc255.tetn  =  target(tpppc.tetn.exp.tax.dir)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.expense.tax)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc255.sern(   
 	   	   	   	  tpppc255.cprj,   
 	   	   	   	  tpppc255.cspa,   
 	   	   	   	  tpppc255.cequ)   
 	   	   	  var.tpppc200.amoc  =  expense.amount   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  etol(tppdm.yeno.no)   
 	   	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc255(   
 	   	   	   	   	  var.tpppc255.tetn,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetn()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc255.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 |  	   	   	  dump 255  	  |   *  from tpppc255, Expense Tax   
 	   	   	  dump.tpppc255()   
 	   	  endif   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:255
:ICOD:S
:QURY:START
select tppdm600.ncmp, tppdm600.cprj, tpppc255.*     
from 	  tppdm600, tpppc255
where 	  tpppc255.cprj refers to tppdm600 unref skip
order by tpppc255._index1  	   	   	  |# 1626994.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:255
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:275
:ICOD:D
:QURY:START
	  var.tpppc200.cprj  =  get.tp.project(tpppc275.cprj)   
 	  var.tpppc200.coob  =  strip$(tpppc275.csub) |#1876758_3.n   
 	  ret.val  =  get.contract.line.via.peg(  	   	  |# FP10.sn   
 	   	   	  tpppc275.cprj,   
 	   	   	  tpppc275.cspa,   
 	   	   	  tpppc275.cact,   
 	   	   	  tpppc275.cstl,   
 	   	   	  var.tpppc200.cono,   
 	   	   	  var.tpppc200.cnln,   
 	   	   	   	  o.err.mess)   
 	  if ret.val  <>  0 then   
 	   	  log.error.data(o.err.mess)   
 	  endif  	   	   	   	  |# FP10.en   
 	  var.tpppc275.tetg  =  etol (tpppc275.tetg)   
 	  if tpppc275.tetg  =  tpppc.tetg.expect then   
 	   	  if tpppc275.srnb  =  0 then   
 	   	   	  var.tpppc275.tetg  =  4   
 	   	  else   
 	   	   	  var.tpppc275.tetg  =  5   
 	   	  endif   
 	  endif   
 	  if (tpppc275.ninv  =  0) then   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.no   
 	  else   
 	   	  var.tpppc200.trsl  =  tppdm.yeno.yes   
 	  endif   
 	  if isspace(tpppc275.ccco) then   
 	   	  var.tpppc200.ccco  =  ""   
 	  else   
 	   	  dummy.long  =  get.cost.components(   
 	   	   	   	  bcorig.tppdm,   
 	   	   	   	  "",   
 	   	   	   	  tpppc275.ccco,   
 	   	   	   	  o.err.mess)   
 	   	  var.tpppc200.ccco  =  bcstc006.cost   
 	  endif   
 	  if tpppc275.invo  =  tppdm.yeno.yes then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	  else   
 	   	  determine.default.value.for.var.tpppc200.blbl(   
 	   	   	   	  tpppc275.cprj,   
 	   	   	   	  tpppc275.cstl)   
 	  endif   
 	  var.tpppc200.srni  =  tpppc275.srni   
 	  var.tpppc200.ftty  =  ""   
 	  var.tpppc200.fdoc  =  0   
 	  tfacp200.pdif  =  0.0   
 	  var.tpppc200.koor  =  etol(tckoor.act.pur)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.act.pur)   
 	  var.tpppc200.orno  =  convert.number(   
 	   	   	   	  var.bcckon.orno ,   
 	   	   	   	  tpppc275.orno)   
 	  if tpppc275.tetg  =  tpppc.tetg.order.invoice then   
 	   	  update.srni.from.tfacp200()   
 	  endif   
 	  var.tpppc200.srnb  =  get.pur.order.line.sequence.number(tpppc275.srnb)   
 	  if isspace(tpppc275.suno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  dummy.long  =  get.business.partner(   
 	   	   	   	  tpppc275.suno,   
 	   	   	   	  bcstc.orgn.suno,   
 	   	   	   	  o.err.mess)   
 	  endif   
 	  dummy.long  =  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)   
 	  var.guid.sern  =  var.guid.sern  +  1   
 	  var.guid.sern.str  =  str$(var.guid.sern)   
 	  var.tpppc200.guid  =  "MIGSUB"  &     
 	   	   	   	  var.guid.sern.str  &     
 	   	   	   	  tpppc275.cprj   
 	  var.tpppc200.amoc  =  tpppc275.amoc   
 	  var.tpppc200.sern  =  tpppc275.sern   
 	  var.tpppc200.pric  =  tpppc275.pric   
 	  var.tpppc200.cdoc  =  tpppc275.cdoc   
 	  var.tpppc200.ncmp  =  tpppc275.ncmp   
 	  if var.tpppc200.comf  =  0 then   
 	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app   
 	  else   
 	   	  var.tpppc200.comf  =  etol(tpppc275.comf)   
 	  endif   
 	  reft.csub  =  read.subcontracting(   
 	   	   	   	  tpppc275.csub,   
 	   	   	   	  tpppc275.cprj,   
 	   	   	   	  desc.csub,   
 	   	   	   	  1,0,0)   
 	  if reft.csub  =  tppdm.reft.standard then   
 	   	  csub.dsbc  	    =  tppdm035.dsbc   
 	  else   
 	   	  csub.dsbc  	    =  tppdm635.dsbc   
 	  endif   
 	  if csub.dsbc  =  tppdm.dsbc.quantity then   
 	   	  var.tpppc200.time  =  0   
 	   	  var.tpppc200.quan  =  tpppc275.quan   
 	   	  var.tpppc200.cuni  =  tpppc275.cuni   
 	   	  var.tpppc200.cuti  =  ""   
 	  else   
 	   	  var.tpppc200.quan  =  0   
 	   	  var.tpppc200.cuni  =  ""   
 	   	  var.tpppc200.time  =  tpppc275.quan   
 	   	  var.tpppc200.cuti  =  tpppc275.cuni   
 	  endif   
 |  	  var.tpppc200.quan  =  tpppc275.quan   
 	  var.tpppc200.amos  =  tpppc275.amos   
 	  get.post.to.finance.tpppc275(   
 	   	   	   	   	  var.tpppc275.tetg,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 	  convert.tpppc200.comf(   
 	   	   	  var.tpppc200.potf,   
 	   	   	  etol(tpppc275.comf),   
 	   	   	  "tpppc275",   
 	   	   	  var.tpppc200.comf)   
 	  fill.vat.fields(   
 	   	   	  tpppc275.cprj,   
 	   	   	  var.tpppc200.txct,   
 	   	   	  var.tpppc200.cvat)   
 	  var.tpppc200.srnb  =  get.order.line.sequence(tpppc275.srnb)   
 	  var.tpppc200.ptyc  =  fill.ptyc.from.tetg()   
 	  convert.tpppc200.koor(   
 	   	   	  var.tpppc200.koor, |   *  long i.tpppc200.koor,   
 	   	   	  tpppc275.orno,   
 	   	   	  var.tpppc200.ptyc,   
 	   	   	  "tpppc275",   
 	   	   	  var.tpppc200.koor)   
 	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	   	  var.tpppc200.curc  =  comp.ccur   
 	   	  var.tpppc200.rtcc(1)  =  1   
 	   	  var.tpppc200.rtcc(2)  =  0   
 	   	  var.tpppc200.rtcc(3)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  1   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(tpppc275.amoc, 1)   
 	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(tpppc275.amoc, 1)   
 	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	   	  var.tpppc200.rdat  =  utc(tpppc275.rgdt,0)   
 	  else   
 	   	  var.tpppc200.curc  =  ""   
 	   	  var.tpppc200.rtcc(1)  =  0   
 	   	  var.tpppc200.rtfc(1)  =  0   
 	   	  var.tpppc200.rtfc(2)  =  0   
 	   	  var.tpppc200.rtfc(3)  =  0   
 	   	  var.tpppc200.cohc(1)  =  0   
 	   	  var.tpppc200.cohd(1)  =  0   
 	   	  var.tpppc200.rtyp  =  ""   
 	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  endif   
 |  	  if cost.history.allow.invoicing(   
 |  	   	   	   	  tpppc275.cprj,   
 |  	   	   	   	  tpppc275.cstl,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  empty,   
 |  	   	   	   	  tpppc275.tetg,   
 |  	   	   	   	  empty)   
 	  if cost.history.allow.invoicing(   
 	   	   	   	  tpppc275.cprj,   
 	   	   	   	  tpppc275.cstl,   
 	   	   	   	  var.tpppc200.ptyc)   
 	  then   
 	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	  var.tpppc200.pris  =  tpppc275.pris   
 	   	  var.tpppc200.amos  =  tpppc275.amos   
 	   	  var.tpppc200.curs  =  comp.ccur   
 	   	  var.tpppc200.rtcs(1)  =  1   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  1   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(tpppc275.rgdt,0)   
 	   	 var.tpppc200.alin  =  tcyesno.yes   
 	  else   
 	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	  var.tpppc200.pris  =  0.0   
 	   	  var.tpppc200.amos  =  0.0   
 	   	  var.tpppc200.curs  =  ""   
 	   	  var.tpppc200.rtcs(1)  =  0   
 |  	   	  var.tpppc200.rtcs(2)  =  0   
 |  	   	  var.tpppc200.rtcs(3)  =  0   
 	   	  var.tpppc200.rtfs(1)  =  0   
 |  	   	  var.tpppc200.rtfs(2)  =  0   
 |  	   	  var.tpppc200.rtfs(3)  =  0   
 	   	  var.tpppc200.rdas  =  utc(0,0)   
 	   	  var.tpppc200.txct  =  ""   
 	   	  var.tpppc200.cvat  =  ""   
 	   	 var.tpppc200.alin  =  tcyesno.no   
 	  endif   
 	  if isspace(tpppc275.orno) then   
 	   	  var.tpppc200.lcor  =  0   
 	  else   
 	   	  var.tpppc200.lcor  =  get.compnr()   
 	  endif   
 |  	  dump 275 |   *  from tpppc275   
 	  dump.tpppc275()   
 	  if tpppc275.tetg  =  tpppc.tetg.order.invoice then   
 	   	  if tfacp200.pdif  <>  0.0 then   
 	  	  	 get.receipt.amount.subcontracting( |  *  KB1876758_5.sn   
 	  	  	  	  	 tpppc275.orno,   
 	  	  	  	  	 tpppc275.pono,   
 	  	  	  	  	 tpppc275.srnb,   
 	  	  	  	  	 receipt.amount)   
 | 	  	  	 if abs(receipt.amount)  <>  tpppc275.amoc then   
 	  	   	   	  	  	  	 |  *  KB1876758_5.en   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc275.tetg  =  target(7) |   *  tpppc.tetg.value.corr   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc275.tetg  =  target(tpppc.tetg.value.corr)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.price.variance)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc275.sern(   
 	   	   	   	  tpppc275.cprj,   
 	   	   	   	  tpppc275.cspa,   
 	   	   	   	  tpppc275.csub)   
 	  	  	  	  	  	  	 |  *  KB1876758.so   
 | 	   	   	  var.tpppc200.amoc  =    -  1  *  tfacp200.pdif   
 	  	  	  	  	  	  	 |  *  KB1876758.eo   
 	   	   	  	  	  	  	  	 |  *  KB1876758.sn   
 	   	   	  var.tpppc200.amoc  =     
 	   	   	  	  	  	 (receipt.amount  +     
 	   	   	  	  	  	  var.tpppc200.amoc)   
 	   	   	  	  	  	  	  	 |  *  KB1876758.en   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  etol(tppdm.yeno.no)   
 	   	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc275(   
 	   	   	   	   	  var.tpppc275.tetg,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetg()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc275.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 |  	   	   	  dump 275  	  |   *  Price Variance   
 	   	   	  dump.tpppc275()   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc275.tetg  =  target(8) |   *  tpppc.tetg.value.corr.rev   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc275.tetg  =  target(tpppc.tetg.value.corr.rev)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.price.var.rev)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc275.sern(   
 	   	   	   	  tpppc275.cprj,   
 	   	   	   	  tpppc275.cspa,   
 	   	   	   	  tpppc275.csub)   
 | 	   	   	  var.tpppc200.amoc  =  tfacp200.pdif 	  |  *  KB1876758.o   
 	   	   	  var.tpppc200.amoc  =    -  1  *  var.tpppc200.amoc 	  |  *  KB1876758.n   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app   
 	   	   	  var.tpppc200.blbl  =  tcyesno.no   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc275(   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	   	   	  8, |   *  tpppc.tetg.value.corr.rev   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	   	   	   	   	  var.tpppc275.tetg, 	 |#1876758.n   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetg()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc275.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 |  	   	   	  dump 275  	  |   *  Price Variance (Reverse posting)   
 	   	   	  dump.tpppc275()   
 | 	   	  	 endif 	  	  	  	  	 |#1876758_5.n   
 	   	  endif   
 	   	  if expense.amount  <>  0.0 then   
 	  	  	  	  	  	  	  	 |#1876758.so   
 | 	   	   	  var.tpppc275.tetg  =  target(6) |   *  tpppc.tetg.exp.tax.dir   
 	  	  	  	  	  	  	  	 |#1876758.eo   
 	  	  	  	  	  	  	  	 |#1876758.sn   
 	   	   	  var.tpppc275.tetg  =  target(tpppc.tetg.exp.tax.dir)   
 	   	   	  var.tpppc200.ptyc  =  target(tpppc.ptyc.expense.tax)   
 	  	  	  	  	  	  	  	 |#1876758.en   
 	   	   	  var.tpppc200.sern  =  get.new.tpppc275.sern(   
 	   	   	   	  tpppc275.cprj,   
 	   	   	   	  tpppc275.cspa,   
 	   	   	   	  tpppc275.csub)   
 	   	   	  var.tpppc200.amoc  =  expense.amount   
 	   	   	  var.tpppc200.pric  =  0   
 	   	   	  var.tpppc200.cdoc  =  ""   
 	   	   	  var.tpppc200.ncmp  =  0   
 	   	   	  var.tpppc200.comf  =  etol(tppdm.yeno.no)   
 	   	   	  var.tpppc200.blbl  =  tcyesno.yes   
 	   	   	  var.tpppc200.quan  =  0   
 	   	   	  var.tpppc200.amos  =  0   
 	   	   	  get.post.to.finance.tpppc275(   
 	   	   	   	   	  var.tpppc275.tetg,   
 	   	   	   	   	  var.tpppc200.cdoc,   
 	   	   	   	   	  var.tpppc200.potf)   
 | 	   	   	  var.tpppc200.ptyc  =  fill.ptyc.from.tetg()|#1876758.o   
 	   	   	  	  	  	  	  	 |#1856315.sn   
 	  	  	  if cost.rates.applicable(var.tpppc200.ptyc) then   
 	  	  	   	  var.tpppc200.curc  =  comp.ccur   
 	  	  	   	  var.tpppc200.rtcc(1)  =  1   
 	  	  	   	  var.tpppc200.rtcc(2)  =  0   
 	  	  	   	  var.tpppc200.rtcc(3)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  1   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(var.tpppc200.amoc, 1)   
 	  	  	   	  var.tpppc200.rtyp  =  bcstp000.crtp   
 	  	  	   	  var.tpppc200.rdat  =  utc(tpppc275.rgdt,0)   
 	  	  	  else   
 	  	  	   	  var.tpppc200.curc  =  ""   
 	  	  	   	  var.tpppc200.rtcc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(1)  =  0   
 	  	  	   	  var.tpppc200.rtfc(2)  =  0   
 	  	  	   	  var.tpppc200.rtfc(3)  =  0   
 	  	  	   	  var.tpppc200.cohc(1)  =  0   
 	  	  	   	  var.tpppc200.cohd(1)  =  0   
 	  	  	   	  var.tpppc200.rtyp  =  ""   
 	  	  	   	  var.tpppc200.rdat  =  utc(0,0)   
 	  	  	  endif   
 	   	   	  	  	  	  	  	 |#1856315.en   
 |  	   	   	  dump 275  	  |   *  from tpppc275, Expense Tax   
 	   	   	  dump.tpppc275()   
 	   	  endif   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:275
:ICOD:S
:QURY:START
select tppdm600.ncmp, tppdm600.cprj, tpppc275.*     
from 	  tppdm600, tpppc275
where 	  tpppc275.cprj refers to tppdm600 unref skip
order by tpppc275._index1  	   	   	  |# 1626994.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:275
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:295
:ICOD:D
:QURY:START
	  var.tpppc200.cprj  =  get.tp.project(tpppc295.cprj)  
 	  var.tpppc200.coob  =  strip$(tpppc295.cico) |#1876758_3.n  
 	  ret.val  =  get.contract.line.via.peg(  	   	  |# FP10.sn  
 	   	   	  tpppc295.cprj,  
 	   	   	  tpppc295.cspa,  
 	   	   	  tpppc295.cact,  
 	   	   	  tpppc295.cstl,  
 	   	   	  var.tpppc200.cono,  
 	   	   	  var.tpppc200.cnln,  
 	   	   	   	  o.err.mess)  
 	  if ret.val  <>  0 then  
 	   	  log.error.data(o.err.mess)  
 	  endif  	   	   	   	  |# FP10.en  
 	  var.tpppc295.tetj  =  etol (tpppc295.tetj)  
 	  if (tpppc295.tetj  =  tpppc.tetj.expected) then  
 	   	  var.tpppc295.tetj  =  7  
 	  else  
 	   	  if (tpppc295.tetj  =  tpppc.tetj.charge) then  
 	   	   	  var.tpppc295.tetj  =  6  	  | Charge Cost  
 	   	  else  
 	   	   	  var.tpppc295.tetj  =  etol(tpppc295.tetj)  
 	   	  endif  
 	  endif  
 	  if (tpppc295.ninv  =  0) then  
 	   	  var.tpppc200.trsl  =  tppdm.yeno.no  
 	  else  
 	   	  var.tpppc200.trsl  =  tppdm.yeno.yes  
 	  endif  
 	  if isspace(tpppc295.ccco) then  
 	   	  var.tpppc200.ccco  =  ""  
 	  else  
 	   	  dummy.long  =  get.cost.components(  
 	   	   	   	  bcorig.tppdm,  
 	   	   	   	  "",  
 	   	   	   	  tpppc295.ccco,  
 	   	   	   	  o.err.mess)  
 	   	  var.tpppc200.ccco  =  bcstc006.cost  
 	  endif  
 	  if tpppc295.invo  =  tppdm.yeno.yes then  
 	   	  var.tpppc200.blbl  =  tcyesno.yes  
 	  else  
 	   	  determine.default.value.for.var.tpppc200.blbl(  
 	   	   	   	  tpppc295.cprj,  
 	   	   	   	  tpppc295.cstl)  
 	  endif  
 	  dummy.long  =  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)  
 	  var.guid.sern  =  var.guid.sern  +  1  
 	  var.guid.sern.str  =  str$(var.guid.sern)  
 	  var.tpppc200.guid  =  "MIGSUN"  &   
 	   	   	   	  var.guid.sern.str  &   
 	   	   	   	  tpppc295.cprj  
 	  if var.tpppc200.comf  =  0 then  
 	   	  var.tpppc200.comf  =  3  	  |   *  tcynna.not.app  
 	  else  
 	   	  var.tpppc200.comf  =  etol(tpppc295.comf)  
 	  endif  
 	  get.post.to.finance.tpppc295(  
 	   	   	   	   	  var.tpppc295.tetj,  
 	   	   	   	   	  var.tpppc200.cdoc,  
 	   	   	   	   	  var.tpppc200.potf)  
 	  fill.vat.fields(  
 	   	   	  tpppc295.cprj,  
 	   	   	  var.tpppc200.txct,  
 	   	   	  var.tpppc200.cvat)  
 	  var.tpppc200.ptyc  =  fill.ptyc.from.tetj()  
 	  convert.tpppc200.koor(  
 	   	   	  var.tpppc200.koor, |   *  long i.tpppc200.koor,  
 	   	   	  0,  
 	   	   	  var.tpppc200.ptyc,  
 	   	   	  "tpppc295",  
 	   	   	  var.tpppc200.koor)  
 	 |  *  For charges the unit should be empty.  
 	 if tpppc295.tetj  =  tpppc.tetj.charge then  
 	  	 var.tpppc200.cuni  =  ""  
 	 endif  
 |  	  if cost.history.allow.invoicing(  
 |  	   	   	   	  tpppc295.cprj,  
 |  	   	   	   	  tpppc295.cstl,  
 |  	   	   	   	  empty,  
 |  	   	   	   	  empty,  
 |  	   	   	   	  empty,  
 |  	   	   	   	  tpppc295.tetj)  
 	  if cost.rates.applicable(var.tpppc200.ptyc) then  
 	   	  var.tpppc200.curc  =  comp.ccur  
 	   	  var.tpppc200.rtcc(1)  =  1  
 	   	  var.tpppc200.rtcc(2)  =  0  
 	   	  var.tpppc200.rtcc(3)  =  0  
 	   	  var.tpppc200.rtfc(1)  =  1  
 	   	  var.tpppc200.rtfc(2)  =  0  
 	   	  var.tpppc200.rtfc(3)  =  0  
 	   	  var.tpppc200.cohc(1)  =  fill.mc.field.double(tpppc295.amoc, 1)  
 	   	  var.tpppc200.cohd(1)  =  fill.mc.field.double(tpppc295.amoc, 1)  
 	   	  var.tpppc200.rtyp  =  bcstp000.crtp  
 	   	  var.tpppc200.rdat  =  utc(tpppc295.rgdt,0)  
 	  else  
 	   	  var.tpppc200.curc  =  ""  
 	   	  var.tpppc200.rtcc(1)  =  0  
 	   	  var.tpppc200.rtfc(1)  =  0  
 	   	  var.tpppc200.rtfc(2)  =  0  
 	   	  var.tpppc200.rtfc(3)  =  0  
 	   	  var.tpppc200.cohc(1)  =  0  
 	   	  var.tpppc200.cohd(1)  =  0  
 	   	  var.tpppc200.rtyp  =  ""  
 	   	  var.tpppc200.rdat  =  utc(0,0)  
 	  endif  
 	  if cost.history.allow.invoicing(  
 	   	   	   	  tpppc295.cprj,  
 	   	   	   	  tpppc295.cstl,  
 	   	   	   	  var.tpppc200.ptyc)  
 	  then  
 	   	  var.tpppc200.blbl  =  tcyesno.yes  
 	   	  var.tpppc200.pris  =  tpppc295.pris  
 	   	  var.tpppc200.amos  =  tpppc295.amos  
 	   	  var.tpppc200.curs  =  comp.ccur  
 	   	  var.tpppc200.rtcs(1)  =  1  
 |  	   	  var.tpppc200.rtcs(2)  =  0  
 |  	   	  var.tpppc200.rtcs(3)  =  0  
 	   	  var.tpppc200.rtfs(1)  =  1  
 |  	   	  var.tpppc200.rtfs(2)  =  0  
 |  	   	  var.tpppc200.rtfs(3)  =  0  
 	   	  var.tpppc200.rdas  =  utc(tpppc295.rgdt,0)  
 	   	 var.tpppc200.alin  =  tcyesno.yes  
 	  else  
 	   	  var.tpppc200.blbl  =  tcyesno.no  
 	   	  var.tpppc200.pris  =  0.0  
 	   	  var.tpppc200.amos  =  0.0  
 	   	  var.tpppc200.curs  =  ""  
 	   	  var.tpppc200.rtcs(1)  =  0  
 |  	   	  var.tpppc200.rtcs(2)  =  0  
 |  	   	  var.tpppc200.rtcs(3)  =  0  
 	   	  var.tpppc200.rtfs(1)  =  0  
 |  	   	  var.tpppc200.rtfs(2)  =  0  
 |  	   	  var.tpppc200.rtfs(3)  =  0  
 	   	  var.tpppc200.rdas  =  utc(0,0)  
 	   	  var.tpppc200.txct  =  ""  
 	   	  var.tpppc200.cvat  =  ""  
 	   	 var.tpppc200.alin  =  tcyesno.no  
 	  endif  
 |  	  if isspace(tpppc295.orno) then There is no tpppc295.orno  
 	   	  var.tpppc200.lcor  =  0  
 |  	  else  
 |  	   	  var.tpppc200.lcor  =  get.compnr()  
 |  	  endif  
 |  	  dump 295 |   *  from tpppc295  
 	  dump.tpppc295()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:295
:ICOD:S
:QURY:START
select tppdm600.ncmp, tppdm600.cprj, tpppc295.*   
from 	  tppdm600, tpppc295
where 	  tpppc295.cprj refers to tppdm600 unref skip
order by tpppc295._index1  	   	   	  |# 1626994.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:200
:SCPAC:tp
:SCMOD:ppc
:SFLNO:295
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:216
:SCPAC:tp
:SCMOD:ppc
:SFLNO:216
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.struct.budget then   
 	   	  var.tpppc216.cprj  =  get.tp.project(tpppc216.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc216.ccco,o.err.mess) then   
 	   	   	  var.tpppc216.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc216.ccco  =  ""    
 	   	  endif   
 	   	  var.tpppc216.item  =  ""    
 	   	  var.str.item.type  =  read.item (tpppc216.item,tpppc216.cprj,var.str.descr,2,0,1)   
 	   	  if var.str.item.type  =  tppdm.reft.standard then   
 	   	   	  temp.cprj  =  ""    
 	   	   	  var.tpppc216.item  =  segment.item.code (tpppc216.item,temp.cprj)   
 	   	  else   
 	   	   	  if var.str.item.type  =  tppdm.reft.project then   
 	   	   	   	  if get.customised.item.linked.to.project(tpppc216.cprj,tpppc216.item,var.pcs.project,var.pcs.item) then   
 	   	   	   	   	  var.cust.project  =  get.ti.project(var.pcs.project)   
 	   	   	   	   	  var.tpppc216.item  =  segment.item.code(var.pcs.item,var.cust.project)   
 	   	   	   	  else   
 	   	   	   	   	  var.tpppc216.item  =  segment.item.code(tpppc216.item,var.tpppc216.cprj)   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	  endif   
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:216
:SCPAC:tp
:SCMOD:ppc
:SFLNO:216
:ICOD:S
:QURY:START
select  	  tpppc216.*  , tppdm600.btco   
from 	  tpppc216, tppdm600
where tpppc216.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:216
:SCPAC:tp
:SCMOD:ppc
:SFLNO:216
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:216
:SCPAC:tp
:SCMOD:ppc
:SFLNO:217
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.activity.budget then   
 	   	  var.tpppc217.cprj  =  get.tp.project(tpppc217.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc217.ccco,o.err.mess) then   
 	   	   	  var.tpppc217.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc217.ccco  =  ""        
 	   	  endif   
 	   	  var.str.item.type  =  read.item (tpppc217.item,tpppc217.cprj,var.str.descr,2,0,1)   
 	   	  if (var.str.item.type  =  tppdm.reft.standard) then   
 	   	   	  temp.cprj  =  ""        
 	   	   	  var.tpppc217.item  =  segment.item.code (tpppc217.item,temp.cprj)   
 	   	  else   
 	   	   	  if (var.str.item.type  =  tppdm.reft.project) then   
 	   	   	   	  if get.customised.item.linked.to.project(tpppc217.cprj,tpppc217.item,var.pcs.project,var.pcs.item) then   
 	   	   	   	   	  var.cust.project  =  get.ti.project(var.pcs.project)   
 	   	   	   	   	  var.tpppc217.item  =  segment.item.code(var.pcs.item,var.cust.project)   
 	   	   	   	  else   
 	   	   	   	   	  var.tpppc217.item  =  segment.item.code(tpppc217.item,var.tpppc217.cprj)   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	  endif   
 	   	  var.tpppc217.cspa  =  ""      
 	   	  if tppdm600.btpr  =  tppdm.bdtp.struct.budget then   
 	   	   	  var.tpppc217.cspa  =  tppdm600.cspa  	    
 	   	  endif  	    
 	   	  dump 2   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:216
:SCPAC:tp
:SCMOD:ppc
:SFLNO:217
:ICOD:S
:QURY:START
select  	  tpppc217.*  ,tppdm600.btpr,tppdm600.btco,tppdm600.cspa   
from 	  tpppc217,tppdm600
where 	  tpppc217.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:216
:SCPAC:tp
:SCMOD:ppc
:SFLNO:217
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:236
:SCPAC:tp
:SCMOD:ppc
:SFLNO:236
:ICOD:D
:QURY:START
if (tppdm600.btco  =  tppdm.bdtp.struct.budget) then   
 	   	  var.tpppc236.cprj  =  get.tp.project(tpppc236.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc236.ccco,o.err.mess) then   
 	   	   	  var.tpppc236.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc236.ccco  =  ""    
 	   	  endif   
 	   	  get.labor.type(bcsbp.orig.tp, tpppc236.cwgt, o.err.mess)  	     
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:236
:SCPAC:tp
:SCMOD:ppc
:SFLNO:236
:ICOD:S
:QURY:START
select  	  tpppc236.*  ,tppdm600.btco   
from 	  tpppc236,tppdm600
where 	  tpppc236.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:236
:SCPAC:tp
:SCMOD:ppc
:SFLNO:236
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:236
:SCPAC:tp
:SCMOD:ppc
:SFLNO:237
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.activity.budget then   
 	   	  var.tpppc237.cprj  =  get.tp.project(tpppc237.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc237.ccco,o.err.mess) then   
 	   	   	  var.tpppc237.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc237.ccco  =  ""    
 	   	  endif   
 	   	  get.labor.type(bcsbp.orig.tp, tpppc237.cwgt, o.err.mess)   
 	   	  var.tpppc237.cspa  =  ""    
 	   	  if tppdm600.btpr  =  tppdm.bdtp.struct.budget then   
 	   	   	  var.tpppc237.cspa  =  tppdm600.cspa  	     
 	   	  endif   
 	   	  dump 2   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:236
:SCPAC:tp
:SCMOD:ppc
:SFLNO:237
:ICOD:S
:QURY:START
select  	  tpppc237.*  ,tppdm600.btpr,tppdm600.btco,tppdm600.cspa   
from 	  tpppc237,tppdm600
where 	  tpppc237.cprj refers to tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:236
:SCPAC:tp
:SCMOD:ppc
:SFLNO:237
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:256
:SCPAC:tp
:SCMOD:ppc
:SFLNO:256
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.struct.budget then   
 	   	  var.tpppc256.cprj  =  get.tp.project(tpppc256.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc256.ccco,o.err.mess) then   
 	   	   	  var.tpppc256.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc256.ccco  =  ""   
 	   	  endif   
 	   	  if isspace (tpppc256.cuti) then   
 	   	   	  tpppc256.cuti  =  tppdm000.ctut   
 	   	  endif   
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:256
:SCPAC:tp
:SCMOD:ppc
:SFLNO:256
:ICOD:S
:QURY:START
select  	  tpppc256.*  ,tppdm600.btco   
from 	  tpppc256,tppdm600
where 	  tpppc256.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:256
:SCPAC:tp
:SCMOD:ppc
:SFLNO:256
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:256
:SCPAC:tp
:SCMOD:ppc
:SFLNO:257
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.activity.budget then   
 	   	  var.tpppc257.cprj  =  get.tp.project(tpppc257.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc257.ccco,o.err.mess) then   
 	   	   	  var.tpppc257.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc257.ccco  =  ""     
 	   	  endif   
 	   	  if isspace (tpppc257.cuti) then   
 	   	   	  tpppc257.cuti  =  tppdm000.ctut   
 	   	  endif   
 	   	  if tppdm600.btpr  =  tppdm.bdtp.struct.budget then   
 	   	   	  var.tpppc257.cspa  =  tppdm600.cspa   
 	   	  endif   
 	   	  dump 2   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:256
:SCPAC:tp
:SCMOD:ppc
:SFLNO:257
:ICOD:S
:QURY:START
select  	  tpppc257.*  ,tppdm600.btpr,tppdm600.btco,tppdm600.cspa   
from 	  tpppc257,tppdm600
where 	  tpppc257.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:256
:SCPAC:tp
:SCMOD:ppc
:SFLNO:257
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:271
:SCPAC:tp
:SCMOD:ppc
:SFLNO:271
:ICOD:D
:QURY:START
var.tpppc271.cprj  =  get.tp.project(tpppc271.cprj)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.act.pur)   
 	  var.tpppc271.orno  =  convert.number(var.bcckon.orno , tpppc271.orno)   
 	   	   	   	   	   	   	   	  |# 241263.so   
 |  	  if not get.cost.components (bcorig.tppdm,"",tpppc271.ccco,o.err.mess) then   
 |  	   	  var.tpppc271.ccco  =  bcstc006.cost   
 |  	  else   
 |  	   	  var.tpppc271.ccco  =  ""   
 |  	  endif   
 |  	  get.business.partner(tpppc271.suno,bcstc.orgn.suno,o.err.mess)   
 	   	   	   	   	   	   	   	  |# 241263.eo   
 	  if isspace(tpppc271.ccco) then  	   	   	   	  |# 241263.sn   
 	   	  var.tpppc271.ccco  =  ""   
 	  else   
 	   	  get.cost.components(bcorig.tppdm,"",tpppc271.ccco,o.err.mess)   
 	   	  var.tpppc271.ccco  =  bcstc006.cost   
 	  endif   
 	  if isspace(tpppc271.ccco) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  get.business.partner(tpppc271.suno,bcstc.orgn.suno,o.err.mess)   
 	  endif  	   	   	   	   	   	   	  |# 241263.en   
 | 	  determine.default.value.for.tpppc271.blbl()   
 	  get.comp()  	   	   	   	  |# 223255.n   
 	  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)   
 	  var.tpppc271.srni  =  tpppc271.srni  	  |# 229038.n   
 	  var.tpppc271.ftty  =  tpppc271.ftty  	  |# 232850.n   
 	  var.tpppc271.fdoc  =  tpppc271.fdoc  	  |# 232850.n   
 	  tfacp200.pdif  =  0.0  	   	   	   	  |# 1040443.n   
 	  on case tpppc271.tetf   
 	  case tpppc.tetf.invoice:   
 	  case tpppc.tetf.order.invoice:   
 	   	  var.tpppc271.ncmp  =  tpppc271.ncmp   
 	   	   	   	   	   	   	  |# 229038.sn   
 	   	  if tpppc271.tetf  =  tpppc.tetf.order.invoice then   
 	   	   	  update.srni.from.tfacp200()   
 	   	  endif  	   	   	   	  |# 229038.en   
 	   	  break   
 	  default:   
 	   	  var.tpppc271.ncmp  =  0   
 	   	  break   
 	  endcase   
 	  var.tpppc271.tetf  =  etol(tpppc271.tetf)  	  |# Correction.n   
 	  var.tpppc271.amoc  =  tpppc271.amoc  	   	   	  |# 237724.sn   
 	  var.tpppc271.sern  =  tpppc271.sern   
 	  var.tpppc271.pric  =  tpppc271.pric   
 	  var.tpppc271.cdoc  =  tpppc271.cdoc   
 	  var.tpppc271.ncmp  =  tpppc271.ncmp   
 	  var.tpppc271.potf  =  tpppc271.potf   
 	  var.tpppc271.quan  =  tpppc271.quan   
 	  var.tpppc271.amos  =  tpppc271.amos  	   	   	  |# 237724.en   
 	  var.tpppc271.srnb  =  get.order.line.sequence(tpppc271.srnb) |# 1110148.n   
 	  determine.posting.type.costs.subcontracting(  	   	  |# FP9.sn   
 	   	   	  var.tpppc271.tetf,   
 	   	   	  posting.type.history.long)   
 | 	  if cost.history.allow.invoicing(   
 | 	   	   	   	  tpppc271.cprj,   
 | 	   	   	   	  tpppc271.cstl,   
 | 	   	   	   	  posting.type.history.long)   
 	 if cost.history.allow.cost.plus.invoicing(   
 	  	  	  	  	 tpppc271.cprj,   
 	  	  	  	  	 tpppc271.cspa,   
 	  	  	  	  	 tpppc271.cact,   
 	  	  	  	  	 tpppc271.cstl,   
 	  	  	  	  	 posting.type.history.long)   
 	  then   
 	   	  var.tpppc271.blbl  =  tcyesno.yes   
 	   	  var.tpppc271.pris  =  tpppc271.pris   
 	   	  var.tpppc271.amos  =  tpppc271.amos   
 	   	  var.tpppc271.curs  =  comp.ccur   
 	   	  var.tpppc271.rtcs(1)  =  1   
 	   	  var.tpppc271.rtcs(2)  =  0   
 	   	  var.tpppc271.rtcs(3)  =  0   
 	   	  var.tpppc271.rtfs(1)  =  1   
 	   	  var.tpppc271.rtfs(2)  =  0   
 	   	  var.tpppc271.rtfs(3)  =  0   
 	   	  var.tpppc271.rdas  =  utc(tpppc271.rgdt,0)   
 |  	   	  var.tpppc271.cohc(1)  =  fill.mc.field.double(tpppc271.amos, 1)   
 |  	   	  var.tpppc271.cohd(1)  =  fill.mc.field.double(tpppc271.amos, 1)   
 	  else   
 	   	  var.tpppc271.blbl  =  tcyesno.no   
 	   	  var.tpppc271.pris  =  0.0   
 	   	  var.tpppc271.amos  =  0.0   
 	   	  var.tpppc271.curs  =  ""   
 	   	  var.tpppc271.rtcs(1)  =  0   
 	   	  var.tpppc271.rtcs(2)  =  0   
 	   	  var.tpppc271.rtcs(3)  =  0   
 	   	  var.tpppc271.rtfs(1)  =  0   
 	   	  var.tpppc271.rtfs(2)  =  0   
 	   	  var.tpppc271.rtfs(3)  =  0   
 	   	  var.tpppc271.rdas  =  utc(0,0)   
 |  	   	  var.tpppc271.txct  =  ""   
 |  	   	  var.tpppc271.cvat  =  ""   
 |  	   	  var.tpppc271.cohc(1)  =  0   
 |  	   	  var.tpppc271.cohd(1)  =  0   
 	  endif   
 	  dump 1   
 	   	   	   	   	   	   	  |# 237724.sn   
 |   *  var.tpppc271.tetf and var.tpppc271.blbl are already filled.   
 	  if tfacp200.pdif  <>  0.0 then   
 |  	   	  var.tpppc271.tetf  =  target(7) |   *  tpppc.tetf.value.corr   
 |  	   	  var.tpppc271.amoc  =    -  1  *  tfacp200.pdif   
 |  	   	  var.tpppc271.pric  =  0   
 |  	   	  var.tpppc271.cdoc  =  ""   
 |  	   	  var.tpppc271.ncmp  =  0   
 |  	   	  var.tpppc271.potf  =  tppdm.yeno.yes   
 |  	   	  var.tpppc271.blbl  =  tcyesno.no   
 |  	   	  var.tpppc271.quan  =  0   
 |  	   	  var.tpppc271.amos  =  0   
 |  	   	  dump 2  	  |   *  Price Variance   
 	   	  var.tpppc271.tetf  =  target(6) |   *  tpppc.tetf.value.corr.rev   
 	   	  var.tpppc271.sern  =  get.new.tpppc271.sern(   
 	   	   	   	  tpppc271.cprj,   
 	   	   	   	  tpppc271.csub)   
 	   	  var.tpppc271.amoc  =    -  1  *  tfacp200.pdif   
 	   	  var.tpppc271.pric  =  0   
 	   	  var.tpppc271.cdoc  =  ""   
 	   	  var.tpppc271.ncmp  =  0   
 	   	  var.tpppc271.potf  =  tppdm.yeno.yes   
 	   	  var.tpppc271.blbl  =  tcyesno.no   
 	   	  var.tpppc271.quan  =  0   
 	   	  var.tpppc271.amos  =  0   
 	   	  dump 3  	  |   *  Price Variance (Reverse posting)   
 	  endif   
 	  if expense.amount  <>  0.0 then   
 	   	  var.tpppc271.tetf  =  target(5) |   *  tpppc.tetf.exp.tax.dir   
 	   	  var.tpppc271.sern  =  get.new.tpppc271.sern(   
 	   	   	   	  tpppc271.cprj,   
 	   	   	   	  tpppc271.csub)   
 	   	  var.tpppc271.amoc  =  expense.amount   
 	   	  var.tpppc271.pric  =  0   
 	   	  var.tpppc271.cdoc  =  ""   
 	   	  var.tpppc271.ncmp  =  0   
 	   	  var.tpppc271.potf  =  tppdm.yeno.no   
 	   	  var.tpppc271.blbl  =  tcyesno.yes   
 	   	  var.tpppc271.quan  =  0   
 	   	  var.tpppc271.amos  =  0   
 	   	  dump 4  	  |   *  Expense Tax   
 	  endif   
 	   	   	   	   	   	   	   	  |# 237724.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:271
:SCPAC:tp
:SCMOD:ppc
:SFLNO:271
:ICOD:S
:QURY:START
select tpppc271.*     
from tpppc271
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:271
:SCPAC:tp
:SCMOD:ppc
:SFLNO:271
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:276
:SCPAC:tp
:SCMOD:ppc
:SFLNO:276
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.struct.budget then   
 	   	  var.tpppc276.cprj  =  get.tp.project(tpppc276.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc276.ccco,o.err.mess) then   
 	   	   	  var.tpppc276.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc276.ccco  =  ""        
 	   	  endif  	    
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:276
:SCPAC:tp
:SCMOD:ppc
:SFLNO:276
:ICOD:S
:QURY:START
select  	  tpppc276.*  ,tppdm600.btco   
from 	  tpppc276,tppdm600
where 	  tpppc276.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:276
:SCPAC:tp
:SCMOD:ppc
:SFLNO:276
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:276
:SCPAC:tp
:SCMOD:ppc
:SFLNO:277
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.activity.budget then   
 	   	  var.tpppc277.cprj  =  get.tp.project(tpppc277.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc277.ccco,o.err.mess) then   
 	   	   	  var.tpppc277.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc277.ccco  =  ""    
 	   	  endif   
 	   	  var.tpppc277.cspa  =  ""    
 	   	  if tppdm600.btpr  =  tppdm.bdtp.struct.budget then   
 	   	   	  var.tpppc277.cspa  =  tppdm600.cspa   
 	   	  endif   
 	   	  dump 2   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:276
:SCPAC:tp
:SCMOD:ppc
:SFLNO:277
:ICOD:S
:QURY:START
select  	  tpppc277.*  ,tppdm600.btpr,tppdm600.btco,tppdm600.cspa   
from 	  tpppc277,tppdm600
where 	  tpppc277.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:276
:SCPAC:tp
:SCMOD:ppc
:SFLNO:277
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:291
:SCPAC:tp
:SCMOD:ppc
:SFLNO:291
:ICOD:D
:QURY:START
	 var.tpppc291.desc  =  tpppc291.desc   
 var.tpppc291.cprj  =  get.tp.project(tpppc291.cprj)   
 	  get.cost.components (bcorig.tppdm,"",tpppc291.ccco,o.err.mess)   
 	  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp , o.err.mess)   
 | 	  determine.default.value.for.tpppc291.blbl()  	  |   *  PR   
 	  var.tpppc291.cohd(1)  =  fill.mc.field.double(tpppc291.amoc, 1)   
 	  var.tpppc291.teti  =  etol(tpppc291.teti)   
 	  determine.posting.type.costs.sundry(  	   	  |# FP9.sn   
 	   	   	  var.tpppc291.teti,   
 | 	   	   	  tpppc291.teti,   
 	   	   	  posting.type.history.long)   
 	 var.tpppc291.desc  =  str$(var.tpppc291.teti)   
 | 	  if cost.history.allow.invoicing(   
 | 	   	   	   	  tpppc291.cprj,   
 | 	   	   	   	  tpppc291.cstl,   
 | 	   	   	   	  posting.type.history.long)   
 	 if cost.history.allow.cost.plus.invoicing(   
 	  	  	  	  	 tpppc291.cprj,   
 	  	  	  	  	 tpppc291.cspa,   
 	  	  	  	  	 tpppc291.cact,   
 	  	  	  	  	 tpppc291.cstl,   
 	  	  	  	  	 posting.type.history.long)   
 	  then   
 	   	  var.tpppc291.blbl  =  tcyesno.yes   
 	   	  var.tpppc291.pris  =  tpppc291.pris   
 	   	  var.tpppc291.amos  =  tpppc291.amos   
 	   	  var.tpppc291.curs  =  comp.ccur   
 	   	  var.tpppc291.rtcs(1)  =  1   
 	   	  var.tpppc291.rtcs(2)  =  0   
 	   	  var.tpppc291.rtcs(3)  =  0   
 	   	  var.tpppc291.rtfs(1)  =  1   
 	   	  var.tpppc291.rtfs(2)  =  0   
 	   	  var.tpppc291.rtfs(3)  =  0   
 	   	  var.tpppc291.rdas  =  utc(tpppc291.rgdt,0)   
 | 	   	  var.tpppc291.cohd(1)  =  fill.mc.field.double(tpppc291.amos, 1)   
 	  else   
 	   	  var.tpppc291.blbl  =  tcyesno.no   
 	   	  var.tpppc291.pris  =  0.0   
 	   	  var.tpppc291.amos  =  0.0   
 	   	  var.tpppc291.curs  =  ""   
 	   	  var.tpppc291.rtcs(1)  =  0   
 	   	  var.tpppc291.rtcs(2)  =  0   
 	   	  var.tpppc291.rtcs(3)  =  0   
 	   	  var.tpppc291.rtfs(1)  =  0   
 	   	  var.tpppc291.rtfs(2)  =  0   
 	   	  var.tpppc291.rtfs(3)  =  0   
 	   	  var.tpppc291.rdas  =  utc(0,0)   
 | 	   	  var.tpppc291.cohd(1)  =  0   
 	  endif   
 	 |  *  tppc291.cohd has to be filled in a multi functional currency (mfc)   
 	 |  *  situation. Since this is default off, cohd does not need to be filled.   
 | 	 if var.tpppc291.teti  =  target(tpppc.teti.manu) then   
 | 	  	 var.tpppc291.cohd(1)  =  fill.mc.field.double(tpppc291.amos, 1)   
 | 	 else   
 	   	 var.tpppc291.cohd(1)  =  0   
 | 	 endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:291
:SCPAC:tp
:SCMOD:ppc
:SFLNO:291
:ICOD:S
:QURY:START
select  	  tpppc291.*  ,tppdm600.ncmp   
from 	  tpppc291,tppdm600
where 	  tpppc291.cprj refers to tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:291
:SCPAC:tp
:SCMOD:ppc
:SFLNO:291
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:296
:SCPAC:tp
:SCMOD:ppc
:SFLNO:296
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.struct.budget then   
 	   	  var.tpppc296.cprj  =  get.tp.project(tpppc296.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc296.ccco,o.err.mess) then   
 	   	   	  var.tpppc296.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc296.ccco  =  ""      
 	   	  endif   
 	   	  if tpppc296.rgdt  <>  0 then   
 	   	   	  var.tpppc296.rdat  =  utc(tpppc296.rgdt,0,2)   
 	   	  else   
 	   	   	  var.tpppc296.rdat  =  utc(date.num(),0)   
 	   	  endif   
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:296
:SCPAC:tp
:SCMOD:ppc
:SFLNO:296
:ICOD:S
:QURY:START
select  	  tpppc296.*  ,tppdm600.btco   
from 	  tpppc296,tppdm600
where 	  tpppc296.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:296
:SCPAC:tp
:SCMOD:ppc
:SFLNO:296
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:296
:SCPAC:tp
:SCMOD:ppc
:SFLNO:297
:ICOD:D
:QURY:START
if tppdm600.btco  =  tppdm.bdtp.activity.budget then   
 	   	  var.tpppc297.cprj  =  get.tp.project(tpppc297.cprj)   
 	   	  if not get.cost.components (bcorig.tppdm,"",tpppc297.ccco,o.err.mess) then   
 	   	   	  var.tpppc297.ccco  =  bcstc006.cost   
 	   	  else   
 	   	   	  var.tpppc297.ccco  =  ""      
 	   	  endif   
 	   	  if tpppc297.rgdt  <>  0 then   
 	   	   	  var.tpppc297.rdat  =  utc(tpppc297.rgdt,0,2)   
 	   	  else   
 	   	   	  var.tpppc297.rdat  =  utc(date.num(),0)   
 	   	  endif   
 	   	  var.tpppc297.cspa  =  ""    
 	   	  if tppdm600.btpr  =  tppdm.bdtp.struct.budget then   
 	   	   	  var.tpppc297.cspa  =  tppdm600.cspa  	    
 	   	  endif   
 	   	  dump 2   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:296
:SCPAC:tp
:SCMOD:ppc
:SFLNO:297
:ICOD:S
:QURY:START
select  	  tpppc297.*  ,tppdm600.btpr,tppdm600.btco,tppdm600.cspa   
from 	  tpppc297,tppdm600
where 	  tpppc297.cprj refers to tppdm600 unref skip
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:296
:SCPAC:tp
:SCMOD:ppc
:SFLNO:297
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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 isspace(tpppc305.ccco) then   
 	   	  var.tpppc305.ccco  =  ""   
 	  else   
 	   	  get.cost.components (bcorig.tppdm,"",tpppc305.ccco,o.err.mess)   
 	   	  var.tpppc305.ccco  =  bcstc006.cost   
 	  endif   
 	  if isspace(tpppc305.cuno) then   
 	   	  bcstc008.bpid  =  ""   
 	  else   
 	   	  get.business.partner(tpppc305.cuno,bcstc.orgn.cuno,o.err.mess)   
 	  endif   
 	  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  =  ""   
 	  var.tpppc305.amhc  =  tpppc305.amor   
 	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin120.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin130.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin140.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin150.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin160.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin170.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin180.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  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   
 	   	  counter  =  false   
 	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin140.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  var.tpppc305.ccty,   
 	   	   	   	   	  var.tpppc305.cvat,   
 	   	   	   	   	  o.err.mess)   
 	   	   	  counter  =  true   
 	   	  selectempty   
 	   	   	  var.tpppc305.ccty  =  ""   
 	   	   	  var.tpppc305.cvat  =  ""   
 	   	  endselect   
 	   	   	  if counter  =  true then   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin150.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  var.tpppc305.ccty,   
 	   	   	   	   	  var.tpppc305.cvat,   
 	   	   	   	   	  o.err.mess)   
 	   	   	  counter  =  true   
 	   	  selectempty   
 	   	   	  var.tpppc305.ccty  =  ""   
 	   	   	  var.tpppc305.cvat  =  ""   
 	   	  endselect   
 	   	   	  if counter  =  true then   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin160.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  var.tpppc305.ccty,   
 	   	   	   	   	  var.tpppc305.cvat,   
 	   	   	   	   	  o.err.mess)   
 	   	   	  counter  =  true   
 	   	  selectempty   
 	   	   	  var.tpppc305.ccty  =  ""   
 	   	   	  var.tpppc305.cvat  =  ""   
 	   	  endselect   
 	   	   	  if counter  =  true then   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin170.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  var.tpppc305.ccty,   
 	   	   	   	   	  var.tpppc305.cvat,   
 	   	   	   	   	  o.err.mess)   
 	   	   	  counter  =  true   
 	   	  selectempty   
 	   	   	  var.tpppc305.ccty  =  ""   
 	   	   	  var.tpppc305.cvat  =  ""   
 	   	  endselect   
 	   	   	  if counter  =  true then   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  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.and.financial.company(   
 	   	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin180.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  var.tpppc305.ccty,   
 	   	   	   	   	  var.tpppc305.cvat,   
 	   	   	   	   	  o.err.mess)   
 	   	   	  counter  =  true   
 	   	  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.and.financial.company(   
 	   	   	   	   	  tppin100.ccty,   
 	   	   	   	   	  tppin190.cvat,   
 	   	   	   	   	  tppdm600.ncmp,   
 	   	   	   	   	  var.tpppc305.ccty,   
 	   	   	   	   	  var.tpppc305.cvat,   
 	   	   	   	   	  o.err.mess)   
 	   	  selectempty   
 	   	   	  var.tpppc305.ccty  =  ""   
 	   	   	  var.tpppc305.cvat  =  ""   
 	   	  endselect   
 	   	  break   
 	  default:   
 	  endcase   
 	  var.tpppc305.bptc  =  get.country.of.financial.company(tppdm600.ncmp)   
 	  var1.tpppc305.ccty  =  ""  	   	   	   	   	   	  |# 210859.sn   
 	  var1.tpppc305.cvat  =  ""   
 	  get.tax.by.country.code.and.financial.company(   
 	   	   	  var.tpppc305.ccty,   
 	   	   	  var.tpppc305.cvat,   
 	   	   	  tppdm600.ncmp,   
 	   	   	  var1.tpppc305.ccty,   
 	   	   	  var1.tpppc305.cvat ,   
 	   	   	  err.mess)   
 	  var.guid.sern  =  var.guid.sern  +  1   
 	  var.guid.sern.str  =  str$(var.guid.sern)   
 	  var.tpppc305.guid  =  "MIGREV"  &  var.guid.sern.str  &  tpppc305.cprj   
 	  var.tpppc305.tetl  =  etol(tpppc305.tetl)   
 	  get.post.to.finance(   
 	   	   	  var.tpppc305.tetl,   
 	   	   	  var.tpppc305.potf)   
 |  	  get.contract.line.via.project.extension(  	   	  |# FP10.so   
 |  	   	   	  tpppc305.cprj,   
 |  	   	   	  tpppc305.cstl,   
 |  	   	   	  var.tpppc305.cono,   
 |  	   	   	  var.tpppc305.cnln)  	   	   	  |# FP10.eo   
 	  ret.val  =  get.contract.line.via.peg(  	   	  |# FP10.sn   
 	   	   	  tpppc305.cprj,   
 	   	   	  tpppc305.cspa,   
 	   	   	  tpppc305.cact,   
 	   	   	  tpppc305.cstl,   
 	   	   	  var.tpppc305.cono,   
 	   	   	  var.tpppc305.cnln,   
 	   	   	   	  o.err.mess)   
 	  if ret.val  <>  0 then   
 	   	  log.error.data(o.err.mess)   
 	  endif  	   	   	   	   	   	  |# FP10.en   
 	  var.tpppc305.koor  =  0   
 	  var.tpppc305.orno  =  ""   
 	  var.tpppc305.pono  =  0   
 	  on case tpppc305.rest   
 	  case tppdm.invt.settlement:   
 	   	  |   *  For extensions the contract is not passed (yet) to   
 	   	  |   *  SLI.`   
 	   	  var.tpppc305.koor  =  58  	  |   *  tpppc.koor.project   
 	   	  var.tpppc305.orno  =  tpppc305.cprj   
 	   	  break   
 |  	  case tppdm.invt.delivery:   
 |  	   	  |   *  does not exist in BaanIV   
 |  	   	  break   
 	  default:   
 	   	  var.tpppc305.koor  =  95  	  |   *  tpppc.koor.proj.contract   
 	   	  var.tpppc305.orno  =  var.tpppc305.cono   
 	   	  break   
 	  endcase   
 	   	  if tpppc305.tetl  =  tpppc.tetl.sal.invoice.fin then   
 	   	   	  var.tpppc305.koor  =  target(tpppc.koor.financial.doc )   
 	   	  else   
 	   	   	  var.tpppc305.koor  =  target(tpppc.koor.not.appl)   
 	   	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:305
:SCPAC:tp
:SCMOD:ppc
:SFLNO:305
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:350
:SCPAC:tp
:SCMOD:ppc
:SFLNO:350
:ICOD:D
:QURY:START
var.tpppc350.cprj  =  get.tp.project(tpppc350.cprj)   
 	  var.guid.sern  =  var.guid.sern  +  1  	  |# 230440.sn   
 	  var.guid.sern.str  =  str$(var.guid.sern)   
 	  var.tpppc350.guid  =  "MIGSUN"  &   var.guid.sern.str  &   tpppc350.cprj   
 	   	   	   	   	   	  |# 230440.en   
 	  var.tpppc350.frgd  =  utc(tpppc350.rgdt,0)   
 	  if tpppc350.prvt  =  tppdm.prvt.costs then   
 | 	   	  var.tpppc350.camr  =  tpppc350.amnt   
 	   	  var.tpppc350.cert  =  bcstp000.crtp   
 | 	   	  var.tpppc350.crdr  =  utc(tpppc350.rgdt,0)   
 	   	  var.tpppc350.rtco  =  tpppc350.cprv   
 | 	   	  var.tpppc350.crtr(1)  =  1   
 | 	   	  var.tpppc350.crfr(1)  =  1   
 | 	   	  var.tpppc350.chcr(1)  =  fill.mc.field.double(tpppc350.amnt, 1)   
 	  else   
 | 	   	  var.tpppc350.camr  =  0.0   
 | 	   	  set.mem(var.tpppc350.chcr, 0.0)   
 	   	  var.tpppc350.cert  =  ""   
 | 	   	  var.tpppc350.crdr  =  utc(0,0)   
 | 	   	  set.mem(var.tpppc350.crtr, 0)   
 | 	   	  set.mem(var.tpppc350.crfr, 0)   
 	   	  var.tpppc350.rtco  =  ""   
 	  endif   
 	  if tpppc350.prvt  =  tppdm.prvt.results then   
 | 	   	  var.tpppc350.ramr  =  tpppc350.amnt   
 	   	  var.tpppc350.rert  =  bcstp000.rrtp   
 | 	   	  var.tpppc350.rrdr  =  utc(tpppc350.rgdt,0)   
 	   	  var.tpppc350.rtre  =  tpppc350.cprv   
 | 	   	  var.tpppc350.rrtr(1)  =  1   
 | 	   	  var.tpppc350.rrfr(1)  =  1   
 | 	   	  var.tpppc350.rhcr(1)  =  fill.mc.field.double(tpppc350.amnt, 1)   
 	  else   
 | 	   	  var.tpppc350.ramr  =  0.0   
 | 	   	  set.mem(var.tpppc350.rhcr, 0.0)   
 	   	  var.tpppc350.rert  =  ""   
 | 	   	  var.tpppc350.rrdr  =  utc(0,0)   
 | 	   	  set.mem(var.tpppc350.rrtr, 0)   
 | 	   	  set.mem(var.tpppc350.rrfr, 0)   
 	   	  var.tpppc350.rtre  =  ""   
 	  endif   
 |  *  These amount and rate fields are only filled when origin is not manual .sn   
 	  var.tpppc350.camr  =  0.0   
 	  set.mem(var.tpppc350.chcr, 0.0)   
 	  var.tpppc350.crdr  =  utc(0,0)   
 	  set.mem(var.tpppc350.crtr, 0)   
 	  set.mem(var.tpppc350.crfr, 0)   
 	  var.tpppc350.ramr  =  0.0   
 	  set.mem(var.tpppc350.rhcr, 0.0)   
 	  var.tpppc350.rrdr  =  utc(0,0)   
 	  set.mem(var.tpppc350.rrtr, 0)   
 	  set.mem(var.tpppc350.rrfr, 0)   
 |  *  These amount and rate fields are only filled when origin is not manual .en   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:350
:SCPAC:tp
:SCMOD:ppc
:SFLNO:350
:ICOD:S
:QURY:START
select  	  tpppc350.*     
from 	  tpppc350
where 	  tpppc350.prvt  <>  tppdm.prvt.provision
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:350
:SCPAC:tp
:SCMOD:ppc
:SFLNO:350
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:000
:SCPAC:tp
:SCMOD:pss
:SFLNO:000
:ICOD:D
:QURY:START
select tppss900.alen   
 	  from tppss900   
 	  where tppss900._index1  =  {1}   
 	  selectdo   
 	   	  var.tppss000.accl  =  tppss900.alen   
 	  selectempty   
 	   	  var.tppss000.accl  =  59 | default()   
 	  endselect   
 	  on case tppss000.ptmu   
 	   	  case tppss.ptmu.week :   
 	   	   	  var.tppss000.sptu  =  tppss000.cuwk   
 	   	   	  break   
 	   	  case tppss.ptmu.day :   
 	   	  case tppss.ptmu.day.percentage :   
 	   	   	  var.tppss000.sptu  =  tppss000.cudy   
 	   	   	  break   
 	   	  case tppss.ptmu.half.day :   
 	   	   	  var.tppss000.sptu  =  tppss000.cuhd   
 	   	   	  break   
 	   	  case tppss.ptmu.hour :   
 	   	   	  var.tppss000.sptu  =  tppss000.cuhr   
 	   	   	  break   
 	   	  case tppss.ptmu.minute :   
 	   	   	  var.tppss000.sptu  =  tppss000.cumi   
 	   	   	  break   
 	   	  default :   
 	   	   	   	   	   	   	   	  |   *  Added to avoid bad files.sn   
 	   	   	  on case bcstp000.ptmu   
 	   	   	  case tppss.ptmu.week :   
 	   	   	   	  var.tppss000.sptu  =  bcstp000.cuwk   
 	   	   	   	  break   
 	   	   	  case tppss.ptmu.day :   
 	   	   	  case tppss.ptmu.day.percentage :   
 	   	   	   	  var.tppss000.sptu  =  bcstp000.cudy   
 	   	   	   	  break   
 	   	   	  case tppss.ptmu.half.day :   
 	   	   	   	  var.tppss000.sptu  =  bcstp000.cuhd   
 	   	   	   	  break   
 	   	   	  case tppss.ptmu.hour :   
 	   	   	   	  var.tppss000.sptu  =  bcstp000.cuhr   
 	   	   	   	  break   
 	   	   	  case tppss.ptmu.minute :   
 	   	   	   	  var.tppss000.sptu  =  bcstp000.cumi   
 	   	   	   	  break   
 	   	   	  endcase  	   	   	   	   	  |   *  Added to avoid bad files.en   
 	   	   	  break   
 	  endcase   
 	  var.tppss000.indt  =  utc(0,0)   
 	  var.tppss000.dsca  =  form.text$("bcstc00035")   
 	  dump 1   
 	  var.tppss000.indt  =  utc(date.num(),time.num())   
 	  var.tppss000.dsca  =  form.text$("bcstc00036")   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:000
:SCPAC:tp
:SCMOD:pss
:SFLNO:000
:ICOD:S
:QURY:START
select tppss000.*     
from tppss000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:000
:SCPAC:tp
:SCMOD:pss
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:200
:SCPAC:tp
:SCMOD:pss
:SFLNO:200
:ICOD:D
:QURY:START
	  if (tppss200.tact  <>  tppdm.tact.milestone) then   
 	   	  var.lng.tppss200.levl  =  1   
 	  else   
 	   	  var.lng.tppss200.levl  =  0   
 	  endif   
 	  if (tppss200.tact  =  tppdm.tact.activity) then   
 	   	  var.lng.tppss200.tact  =  4   
 	  else   
 	   	  var.lng.tppss200.tact  =  5   
 	  endif   
 	  if (tppss200.tact  <>  tppdm.tact.milestone) then   
 	   	  var.tppdm.cact.tppss200.cpra  =  bcstp000.cpac  	  | get.string(1)   
 	   	  var.lng.tppss200.cctr  =  1   
 	  else   
 	   	  var.tppdm.cact.tppss200.cpra  =  empty.string (1;8)   
 	   	  var.lng.tppss200.cctr  =  2   
 	  endif   
 	  if (tppss200.stat  =  empty) then   
 	   	  var.lng.tppss200.stat  =  1   
 	  else   
 	   	  var.lng.tppss200.stat  =  etol (tppss200.stat)   
 	  endif   
 	  if (tppss200.tact  =  tppdm.tact.milestone) then   
 	   	  var.lng.tppss200.lvps  =  target(tppss.lvps.na)   
 	  else   
 	   	  if (tppss200.lvps  =  empty) then   
 	   	   	  var.lng.tppss200.lvps  =  1   
 	   	  else   
 	   	   	  var.lng.tppss200.lvps  =  etol (tppss200.lvps)   
 	   	  endif   
 	  endif   
 	  var.lng.tppss200.capt  =  etol (tppss200.capt)   
 	  select tppdm600.btco, tppdm600.invm, tppdm600.stdt, tppdm600.psts,   
 	   	  tppdm600.bdmt   
 	  from  	  tppdm600   
 	  where  	  tppdm600._index1  =  {:tppss200.cprj}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  if tppdm600.btco  <>  tppdm.bdtp.activity.budget then   
 	   	   	  var.tppss200.prin  =  4 | target(tppdm.prin.na)   
 	   	   	  var.tppss200.cspt  =  3 | target(tpptc.cspt.na)   
 	   	  else   
 	   	   	  on case tppdm600.invm   
 	   	   	  case tppdm.invm.unit.rate:   
 	   	   	   	  var.tppss200.prin  =  2 | tppdm.prin.no   
 	   	   	   	  var.tppss200.cspt  =  1 | tpptc.cspt.direct   
 	   	   	   	  break   
 	   	   	  case tppdm.invm.inst.spec:   
 	   	   	   	  var.tppss200.prin  =  2 | tppdm.prin.no   
 	   	   	   	  var.tppss200.cspt  =  3 | target(tpptc.cspt.na)   
 	   	   	   	  break   
 	   	   	  case tppdm.invm.instalment:   
 	   	   	  case tppdm.invm.prime.cost:   
 	   	   	   	  var.tppss200.prin  =  4 | target(tppdm.prin.na)   
 	   	   	   	  var.tppss200.cspt  =  3 | target(tpptc.cspt.na)   
 	   	   	   	  break   
 	   	   	  endcase   
 	   	  endif   
 	   	  if tppdm600.stdt  <>  0 then   
 	   	   	  rate.date  =  utc(tppdm600.stdt,time.num())   
 	   	  else   
 	   	   	  rate.date  =  utc(date.num(), time.num())   
 	   	  endif  	   	   	   	  | review.en   
 	   	  on case tppdm600.psts   
 	   	  case tppdm.psts.free:   
 	   	   	  var.tppss200.wast  =  1  	  | tppdm.wast.free   
 	   	   	  break   
 	   	  case tppdm.psts.construction:   
 	   	   	  var.tppss200.wast  =  3  	  | tppdm.wast.released   
 	   	   	  break   
 	   	  case tppdm.psts.finished:   
 	   	   	  var.tppss200.wast  =  4  	  | tppdm.wast.finished   
 	   	   	  break   
 	   	  case tppdm.psts.closed:   
 	   	   	  var.tppss200.wast  =  5  	  | tppdm.wast.closed   
 	   	   	  break   
 	   	  case tppdm.psts.archived:   
 	   	   	  var.tppss200.wast  =  5  	  | tppdm.wast.closed   
 	   	   	  break   
 	   	  endcase   
 	   	  if tppss200.stat  =  tpptc.stat.free then   
 	   	   	  var.tppss200.wast  =  1  	  | tppdm.wast.free   
 	   	  endif   
 	  endselect   
 	  if tppss200.psdt  <>  0 and tppss200.pfdt  <>  0 then   
 	   	  var.lng.psdp  =  var.lng.start  +  ((tppss200.psdp  *  var.dbl.duration)  *  60  *  60)   
 	   	  var.lng.pfdp  =  var.lng.start  +  ((tppss200.pfdp  *  var.dbl.duration)  *  60  *  60)   
 	   	  var.fstr.tppss200.psdt  =  utc (tppss200.psdt,var.lng.psdp)   
 	   	  var.fstr.tppss200.pfdt  =  utc (tppss200.pfdt,var.lng.pfdp)   
 	  else   
 	   	  var.fstr.tppss200.psdt  =  utc(0,0)   
 	   	  var.fstr.tppss200.pfdt  =  utc(0,0)   
 	  endif   
 	  var.tppdm.dprt.desc  =  0.0   
 	  var.tppdm.s080.err  =  ""   
 	  var.dbl.tppss200.pcom  =  tppss200.pcom   
 	  var.tppdm.date.tppss200.afdt  =  tppss200.afdt   
 	  var.tppdm.date.tppss200.asdt  =  tppss200.asdt   
 	  if (tppss200.tact  <>  tppdm.tact.milestone) then   
 	   	  var.str.temp.tppss200.asdt  =  utc (var.tppdm.date.tppss200.asdt,0)   
 	   	  var.str.temp.tppss200.afdt  =  utc (var.tppdm.date.tppss200.afdt,0)   
 	  else   
 	   	  var.str.temp.tppss200.afdt  =  utc (var.tppdm.date.tppss200.asdt,0)   
 	   	  var.str.temp.tppss200.asdt  =  var.str.temp.tppss200.afdt   
 	  endif   
 	  if (tppss200.stat  =  tpptc.stat.free) then   
 	   	  var.str.temp.tppss200.asdt  =  utc (0,0)   
 	   	  var.str.temp.tppss200.afdt  =  utc (0,0)   
 	  endif   
 	   	   	   	   	   	   	   	  |# FP9.sn   
 	  if currency.rates.applicable() then   
 	   	   	  var.tppss200.sacu  =  comp.ccur   
 	   	   	  var.tppss200.rdas  =  rate.date   
 	   	   	  var.tppss200.rtsa(1)  =  1   
 	   	   	  var.tppss200.rtsa(2)  =  0   
 	   	   	  var.tppss200.rtsa(3)  =  0   
 	   	   	  var.tppss200.rfsa(1)  =  1   
 	   	   	  var.tppss200.rfsa(2)  =  0   
 	   	   	  var.tppss200.rfsa(3)  =  0   
 	  else   
 	   	   	  set.mem(var.tppss200.rtsa, 0)   
 	   	   	  set.mem(var.tppss200.rfsa, 0)   
 	   	   	  var.tppss200.rdas  =  utc(0 ,0 )   
 	  endif   
 	   	   	   	   	   	   	   	  |# FP9.en   
 |   *  tppss200.setl is default no   
 	  var.tppss200.secu  =  ""   
 	  var.tppss200.rtse.1  =  0   
 	  var.tppss200.rtse.2  =  0   
 	  var.tppss200.rtse.3  =  0   
 	  var.tppss200.rfse.1  =  0   
 	  var.tppss200.rfse.2  =  0   
 	  var.tppss200.rfse.3  =  0   
 	  var.tppss200.rdse  =  utc(0,0)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:200
:SCPAC:tp
:SCMOD:pss
:SFLNO:200
:ICOD:S
:QURY:START
select  	  tppss200.*     
from 	  tppss200
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:200
:SCPAC:tp
:SCMOD:pss
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:600
:SCPAC:tp
:SCMOD:pss
:SFLNO:600
:ICOD:D
:QURY:START
var.tppss600.orno  =  empty.string(1;9)   
 	  var.tppss600.item  =  empty.string (1;47)   
 	  var.tppss600.aitm  =  empty.string (1;47)   
 	  get.cost.components(bcorig.tppdm,"",tppss600.ccco,err.mess)   
 	  var.tppss600.cprj  =  get.tp.project(tppss600.cprj)   
 	  if (tppss600.reft  =  tppdm.reft.project) then   
 	   	  if get.customised.item.linked.to.project(tppss600.cprj,tppss600.item,var.pcs.project,var.pcs.item) then   
 	   	   	  var.cust.project  =  get.ti.project(var.pcs.project)   
 	   	   	  var.tppss600.item  =  segment.item.code(var.pcs.item,var.cust.project)   
 	   	  else   
 	   	   	  var.tppss600.item  =  segment.item.code(tppss600.item,var.tppss600.cprj)   
 	   	  endif   
 	  else   
 	   	  if (tppss600.reft  =  tppdm.reft.standard) then   
 	   	   	  var.tppss600.item  =  segment.item.code (tppss600.item,"")   
 	   	  endif   
 	  endif   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tppss600.koor)   
 	  var.tppss600.orno  =  convert.number(var.bcckon.orno , tppss600.orno)   
 	  var.tppss600.koor  =  convert.tckoor(tppss600.koor,tppss600.orno)   
 	  if tppss600.koor  =  tckoor.pss.wrh then   
 	   	  select  	  tppss615.witm   
 	   	  from  	  tppss615   
 	   	  where  	  tppss615._index1  =  {:tppss600.cprj,:tppss600.orno}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	   	  var.tppss600.aitm  =  segment.item.code(tppss615.witm,"")   
 	   	  endselect   
 	  endif   
 	  if tppss600.koor  =  empty and   
 	  not isspace(tppss600.orno) then   
 	   	  var.tppss600.koor  =  target(tckoor.act.pur.req)   
 	  endif   
 	  if isspace(tppss600.orno) or   
 	   	  tppss600.koor  <>  tckoor.act.pur   
 	  then   
 	   	  var.tppss600.sqnb  =  0   
 	  else   
 	   	  var.tppss600.sqnb  =  1   
 	  endif   
 	     
 |  	  case tckoor.act.rpl:   
 |  	  case tckoor.pcs.wrh:   
 |  	   	  var.tppss600.koor  =  58  	   	  | Project   
 |  	   	  break   
 |  	  case tckoor.ti.wrh:   
 |  	   	  var.tppss600.koor  =  19  	   	  | tckoor.pss.wrh   
 |  	   	  break   
 |  	  default:   
 |  	   	  var.tppss600.koor  =  etol (tppss600.koor)   
 |  	  endcase   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:600
:SCPAC:tp
:SCMOD:pss
:SFLNO:600
:ICOD:S
:QURY:START
select  	  tppss600.*    
from tppss600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:600
:SCPAC:tp
:SCMOD:pss
:SFLNO:600
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:601
:SCPAC:tp
:SCMOD:pss
:SFLNO:601
:ICOD:D
:QURY:START
var.tppss601.orno  =  empty.string(1;9)   
 	  var.tppss601.koor  =  convert.tckoor(tppss601.koor,tppss601.orno)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tppss601.koor)   
 	  var.tppss601.orno  =  convert.number(var.bcckon.orno,tppss601.orno)   
 	  if isspace(tppss601.orno) or   
 	    	  tppss601.koor  <>  tckoor.act.pur   
 	  then   
 	    	  var.tppss601.sqnb  =  0   
 	  else   
 	    	  var.tppss601.sqnb  =  1   
 	  endif   
 	  get.cost.components(bcorig.tppdm,"",tppss601.ccco,err.mess)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:601
:SCPAC:tp
:SCMOD:pss
:SFLNO:601
:ICOD:S
:QURY:START
select  	  tppss601.*   
from 	  tppss601
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:601
:SCPAC:tp
:SCMOD:pss
:SFLNO:601
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:602
:SCPAC:tp
:SCMOD:pss
:SFLNO:602
:ICOD:D
:QURY:START
var.tppss602.orno  =  empty.string(1;9)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tppss602.koor)   
 	  var.tppss602.orno  =  convert.number(var.bcckon.orno , tppss602.orno)   
 	  var.tppss602.koor  =  convert.tckoor(tppss602.koor,tppss602.orno)   
 	  if isspace(tppss602.orno) or   
 	    	  tppss602.koor  <>  tckoor.act.pur   
 	  then   
 	    	  var.tppss602.sqnb  =  0   
 	  else   
 	    	  var.tppss602.sqnb  =  1   
 	  endif   
 	  get.cost.components(bcorig.tppdm,"",tppss602.ccco,err.mess)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:602
:SCPAC:tp
:SCMOD:pss
:SFLNO:602
:ICOD:S
:QURY:START
select tppss602.*   
from tppss602
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:602
:SCPAC:tp
:SCMOD:pss
:SFLNO:602
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:605
:SCPAC:tp
:SCMOD:pss
:SFLNO:605
:ICOD:D
:QURY:START
var.tppss605.orno  =  empty.string(1;9)   
 	  var.tppss605.item  =  empty.string (1;47)   
 	  var.tppss605.cprj  =  get.tp.project(tppss605.cprj)   
 	  var.tppdm.reft.item.type  =  read.item (tppss605.item,tppss605.cprj,var.tppdm.desc.descr,2,0,1)   
 	  if (var.tppdm.reft.item.type  =  tppdm.reft.project) then   
 	    	  var.tppss605.item  =  segment.item.code (tppss605.item,var.tppss605.cprj)   
 	  else   
 	    	  if (var.tppdm.reft.item.type  =  tppdm.reft.standard) then   
 	    	    	  var.tppss605.item  =  segment.item.code (tppss605.item,"")   
 	    	  endif   
 	  endif   
 	  var.tppss605.koor  =  convert.tckoor(tppss605.koor,tppss605.orno)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tppss605.koor)   
 	  var.tppss605.orno  =  convert.number(var.bcckon.orno,tppss605.orno)   
 	  if tppss605.koor  <>  tckoor.act.pur   
 	  then   
 	    	  var.tppss605.sqnb  =  0   
 	  else   
 	    	  var.tppss605.sqnb  =  1   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:605
:SCPAC:tp
:SCMOD:pss
:SFLNO:605
:ICOD:S
:QURY:START
select tppss605.*   
from tppss605
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:605
:SCPAC:tp
:SCMOD:pss
:SFLNO:605
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:610
:SCPAC:tp
:SCMOD:pss
:SFLNO:610
:ICOD:D
:QURY:START
var.tppss610.item  =  empty.string (1;47)   
 	  var.tppss610.orno  =  empty.string(1;9)   
 	  var.tppss610.cono  =  empty.string(1;9)   
 	  var.tppss610.cprj  =  get.tp.project(tppss610.cprj)   
 	  if save.ncmp  <>  tppdm600.ncmp then   
 	   	  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp,err.mess)   
 	   	  save.ncmp  =  tppdm600.ncmp   
 	  endif   
 	  if isspace(tppss610.ccco) then  	     
 	   	  bcstc006.cost  =  ""    
 	  else   
 	   	  get.cost.components(bcorig.tppdm,"",tppss610.ccco,err.mess)   
 	  endif   
 	  if isspace(tppss610.suno) then   
 	   	  bcstc008.bpid  =  ""    
 	  else   
 	   	  get.business.partner(tppss610.suno,bcstc.orgn.suno,err.mess)   
 	  endif  	   	   	   	   	   	   	  |# 241263.en   
 	  var.tppdm.reft.item.type  =  read.item (tppss610.item,tppss610.cprj,var.tppdm.desc.descr,2,0,1)   
 	  if var.tppdm.reft.item.type  =  tppdm.reft.project then   
 	   	  var.tppss610.item  =  segment.item.code (tppss610.item,var.tppss610.cprj)   
 	  else   
 	   	  if var.tppdm.reft.item.type  =  tppdm.reft.standard then   
 	   	   	  var.tppss610.item  =  segment.item.code (tppss610.item,"")   
 	   	  endif   
 	  endif   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.pss.pur)   
 	  var.tppss610.orno  =  convert.number(var.bcckon.orno , tppss610.orno)   
 	  var.tppss610.cono  =  convert.number(bcckon.act.pur.contr, tppss610.cono)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:610
:SCPAC:tp
:SCMOD:pss
:SFLNO:610
:ICOD:S
:QURY:START
select  	  tppss610.*  ,tppdm600.ncmp   
from tppss610,tppdm600
where tppss610.cprj refers to tppdm600 UNREF SKIP
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:610
:SCPAC:tp
:SCMOD:pss
:SFLNO:610
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:611
:SCPAC:tp
:SCMOD:pss
:SFLNO:611
:ICOD:D
:QURY:START
var.tppss611.orno  =  empty.string(1;9)   
 	  var.tppss611.cono  =  empty.string(1;9)   
 	  if save.ncmp  <>  tppdm600.ncmp then   
 	   	  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp,err.mess)   
 	   	  save.ncmp  =  tppdm600.ncmp   
 	  endif   
 	  if isspace(tppss611.ccco) then  	   	   	   	  |# 241263.sn   
 	   	  bcstc006.cost  =  ""    
 	  else   
 	   	  get.cost.components(bcorig.tppdm,"",tppss611.ccco,err.mess)   
 	  endif   
 	  if isspace(tppss611.suno) then   
 	   	  bcstc008.bpid  =  ""    
 	  else   
 	   	  get.business.partner(tppss611.suno,bcstc.orgn.suno,err.mess)   
 	  endif  	   	   	   	   	   	   	  |# 241263.en   
 	  var.tppss611.cono  =  convert.number(bcckon.act.pur.contr, tppss611.cono)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.pss.pur)   
 	  var.tppss611.orno  =  convert.number(var.bcckon.orno , tppss611.orno)   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:611
:SCPAC:tp
:SCMOD:pss
:SFLNO:611
:ICOD:S
:QURY:START
select tppss611.*  ,tppdm600.ncmp   
from tppss611,tppdm600
where tppss611.cprj refers to tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:611
:SCPAC:tp
:SCMOD:pss
:SFLNO:611
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:612
:SCPAC:tp
:SCMOD:pss
:SFLNO:612
:ICOD:D
:QURY:START
var.tppss612.orno  =  empty.string(1;9)   
 	  var.tppss612.cono  =  empty.string(1;9)   
 	  if save.ncmp  <>  tppdm600.ncmp then   
 	   	  get.enterprise.unit(tppdm600.ncmp,ext.lng.comp,err.mess)   
 	   	  save.ncmp  =  tppdm600.ncmp   
 	  endif   
 	  if isspace(tppss612.ccco) then  	   	   	   	  |# 241263.sn   
 	   	  bcstc006.cost  =  ""    
 	  else   
 	   	  get.cost.components(bcorig.tppdm,"",tppss612.ccco,err.mess)   
 	  endif  	   	   	   	   	   	   	  |# 241263.en   
 	  if isspace(tppss612.suno) then  	   	   	   	  |# 241263.sn   
 	   	  bcstc008.bpid  =  ""    
 	  else   
 	   	  get.business.partner(tppss612.suno,bcstc.orgn.suno,err.mess)   
 	  endif  	   	   	   	   	   	   	  |# 241263.en   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.pss.pur)   
 	  var.tppss612.orno  =  convert.number(var.bcckon.orno , tppss612.orno)   
 	  var.tppss612.cono  =  convert.number(bcckon.act.pur.contr, tppss612.cono)   
 	  csub.reft  =  read.subcontracting(tppss612.csub,tppss612.cprj,csub.desc,2,1,1)   
 	  if ipdm0010.dsbc  =  tppdm.dsbc.quantity and tppss612.oqtm  <>  0 then   
 	   	  tppss612.oqtm  =  0   
 	  endif   
 	  if ipdm0010.dsbc  =  tppdm.dsbc.time and tppss612.oqan  <>  0 then   
 	   	  tppss612.oqan  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:612
:SCPAC:tp
:SCMOD:pss
:SFLNO:612
:ICOD:S
:QURY:START
select tppss612.*  ,tppdm600.ncmp   
from tppss612,tppdm600
where tppss612.cprj refers to tppdm600
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:612
:SCPAC:tp
:SCMOD:pss
:SFLNO:612
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:615
:SCPAC:tp
:SCMOD:pss
:SFLNO:613
:ICOD:D
:QURY:START
var.tppss615.orno  =  empty.string(1;9)   
 	  get.cost.components(bcorig.tppdm,"",tppss613.ccco,err.mess)   
 	  var.tppss615.ccco  =  bcstc006.cost   
 	  var.tppss615.cprj  =  get.tp.project(tppss613.cprj)   
 	  var.tppss615.pitm  =  empty.string(1;47)   
 	  get.customised.item.linked.to.project(tppss613.cprj,tppss613.item,var.pcs.project,var.pcs.item)   
 	  var.cust.project  =  get.ti.project(var.pcs.project)   
 	  var.tppss615.pitm  =  segment.item.code(var.pcs.item,var.cust.project)   
 	  var.tppss615.witm  =  var.tppss615.pitm   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.ti.wrh)   
 	  var.tppss615.orno  =  convert.number(var.bcckon.orno , tppss613.orno)   
 	  if tppdm600.cwar  =  "" then   
 	   	  var.tppdm600.cwar  =  tiitm001.cwar   
 	  else   
 	   	  var.tppdm600.cwar  =  tppdm600.cwar   
 	  endif   
 	  set.max(var.tppss615.prio, "tppdm.long")   
 	  dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:615
:SCPAC:tp
:SCMOD:pss
:SFLNO:613
:ICOD:S
:QURY:START
select tppss613.*  ,tppdm600.cwar,   
 	  tiitm001.cwar   
from tppss613,tppdm600,   
 	  tiitm001
where tppdm600._index1  =  {tppss613.cprj}   
 and  	  tiitm001.item  =  tppss613.item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:615
:SCPAC:tp
:SCMOD:pss
:SFLNO:613
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:615
:SCPAC:tp
:SCMOD:pss
:SFLNO:615
:ICOD:D
:QURY:START
var.tppss615.witm  =  empty.string (1;47)   
 	  var.tppss615.pitm  =  empty.string (1;47)   
 	  var.tppss615.orno  =  empty.string(1;9)   
 	  var.tppss615.cprj  =  get.tp.project(tppss615.cprj)   
 	  var.tppss615.witm  =  segment.item.code (tppss615.witm,"")   
 	  var.tppdm.reft.hold.item  =  read.item (tppss615.pitm,var.tppss615.cprj,var.tppdm.desc.descr,2,0,1)   
 	  if var.tppdm.reft.hold.item  =  tppdm.reft.project then   
 	   	  var.tppss615.pitm  =  segment.item.code (tppss615.pitm,var.tppss615.cprj)   
 	  else   
 	   	  if var.tppdm.reft.hold.item  =  tppdm.reft.standard then   
 	   	   	  var.tppss615.pitm  =  segment.item.code (tppss615.pitm,"")   
 	   	  endif   
 	  endif   
 	  get.cost.components(bcorig.tppdm,"",tppss615.ccco,err.mess)   
 	  var.tppss615.ccco  =  bcstc006.cost   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tckoor.pss.wrh)   
 	  var.tppss615.orno  =  convert.number(var.bcckon.orno , tppss615.orno)   
 	  if tppss615.delt  =  tppss.delt.pw then   
 	   	  var.tppss615.uwop  =  1  	  | tppdm.yeno.yes   
 	   	  var.tppss615.pric  =  tppss615.pric   
 	  else   
 	   	  var.tppss615.uwop  =  2  	  | tppdm.yeno.no   
 	   	  var.tppss615.pric  =  0.0   
 	  endif   
 	  var.tppdm600.cwar  =  tppss615.cwar   
 	  set.max(var.tppss615.prio, "tppdm.long")   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:615
:SCPAC:tp
:SCMOD:pss
:SFLNO:615
:ICOD:S
:QURY:START
select  	  tppss615.*     
from 	  tppss615
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:615
:SCPAC:tp
:SCMOD:pss
:SFLNO:615
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:651
:SCPAC:tp
:SCMOD:pss
:SFLNO:651
:ICOD:D
:QURY:START
var.tppss651.orno  =  empty.string(1;9)   
 	  if tppss651.quan  <  0.0 then   
 	    	  var.tppss651.quan  =  tppss651.quan  *    -  1   
 	  else   
 	    	  var.tppss651.quan  =  tppss651.quan   
 	  endif   
 	  if isspace(tppss651.ccco) then  	    	    	    	   | # 241263.sn   
 	    	  bcstc006.cost  =  ""   
 	  else   
 	    	  get.cost.components(bcorig.tppdm,"",tppss651.ccco,err.mess)   
 	  endif  	    	    	    	    	    	    	   | # 241263.en   
 	  if isspace(tppss651.suno) then  	    	    	    	   | # 241263.sn   
 	    	  bcstc008.bpid  =  ""   
 	  else   
 	    	  get.business.partner(tppss651.suno,bcstc.orgn.suno,err.mess)   
 	  endif  	    	    	    	    	    	    	   | # 241263.en   
 	  var.tppss651.kost  =  convert.tckost(tppss651.kost,tppss651.quan)   
 	  var.tppss651.koor  =  convert.tckoor(tppss651.koor,tppss651.orno)   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tppss651.koor)   
 	  var.tppss651.orno  =  convert.number(var.bcckon.orno , tppss651.orno)   
 	  if isspace(var.tppss651.orno) or   
 	    	  tppss651.koor  <>  tckoor.act.pur   
 	  then   
 	    	  var.tppss651.sqnb  =  0   
 	  else   
 	    	  var.tppss651.sqnb  =  1   
 	  endif   
 	  generate.sequence.number() | # 230440..n   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:651
:SCPAC:tp
:SCMOD:pss
:SFLNO:651
:ICOD:S
:QURY:START
select tppss651.*   
from tppss651
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:651
:SCPAC:tp
:SCMOD:pss
:SFLNO:651
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:652
:SCPAC:tp
:SCMOD:pss
:SFLNO:652
:ICOD:D
:QURY:START
var.tppss652.orno  =  empty.string(1;9)   
 	  if tppss652.quan  <  0.0 then   
 	    	  var.tppss652.quan  =  tppss652.quan  *    -  1   
 	  else   
 	    	  var.tppss652.quan  =  tppss652.quan   
 	  endif   
 	  if isspace(tppss652.ccco) then  	    	    	    	   | # 241263.sn   
 	    	  bcstc006.cost  =  ""    
 	  else   
 	    	  get.cost.components(bcorig.tppdm,"",tppss652.ccco,err.mess)   
 	  endif   
 	  if isspace(tppss652.suno) then   
 	    	  bcstc008.bpid  =  ""    
 	  else   
 	    	  get.business.partner(tppss652.suno,bcstc.orgn.suno,err.mess)   
 	  endif  	    	    	    	    	    	    	   | # 241263.en   
 	  var.bcckon.orno  =  convert.tckoor.to.bcckon(tppss652.koor)   
 	  var.tppss652.orno  =  convert.number(var.bcckon.orno , tppss652.orno)   
 	  var.tppss652.koor  =  convert.tckoor(tppss652.koor,tppss652.orno)   
 	  if isspace(var.tppss652.orno) or   
 	    	  tppss652.koor  <>  tckoor.act.pur   
 	  then   
 	    	  var.tppss652.sqnb  =  0   
 	  else   
 	    	  var.tppss652.sqnb  =  1   
 	  endif   
 	  var.tppss652.kost  =  convert.tckost(tppss652.kost,tppss652.quan)   
 	  generate.sequence.number()  	   | # 230440..n   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:652
:SCPAC:tp
:SCMOD:pss
:SFLNO:652
:ICOD:S
:QURY:START
select  	  tppss652.*   
from tppss652
order by tppss652._index1  	    	    	   | # 250338.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:pss
:TFLNO:652
:SCPAC:tp
:SCMOD:pss
:SFLNO:652
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:000
:SCPAC:tp
:SCMOD:ptc
:SFLNO:000
:ICOD:S
:QURY:START
select tpptc000.*    
from tpptc000
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:000
:SCPAC:tp
:SCMOD:ptc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:050
:SCPAC:tp
:SCMOD:ptc
:SFLNO:050
:ICOD:D
:QURY:START
|get.business.partner(tpptc050.cuno,bcstc.orgn.cuno,err.mess) 	 |# 241263.o   
 	 if isspace(tpptc050.cuno) then 	  	  	  	 |# 241263.sn   
 	  	 bcstc008.bpid  =  ""     
 	 else   
 	  	 get.business.partner(tpptc050.cuno,bcstc.orgn.cuno,err.mess)   
 	 endif 	  	  	  	  	  	  	 |# 241263.en   
 	 if tpptc050.excc  =  tppdm.yeno.yes and   
 	 tpptc050.lpsl  =  empty then   
 	  	 tpptc050.lpsl  =  tppdm.lpsl.settl.costctr   
 	 endif   
 	 var.bcstc.keys.temp.add  =  tpptc050.cprj  &  tpptc050.cstl   
 	 get.addresses("tpptc050",var.bcstc.keys.temp.add,err.mess)   
 	 if tccom999.txpr  =  tcyesno.yes then   
 	  	 var.tpptc050.sadr  =  bcstc004.cadr   
 	 else   
 	  	 var.tpptc050.sadr  =  empty.string (1;9)   
 	 endif   
 	 if tpptc050.stin  =  tppdm.stin.final then   
 	  	 select 	 tppin100.cprj   
 	  	 from 	 tppin100   
 	  	 where 	 tppin100._index1  =  {:tpptc050.stin,:tpptc050.ninv} and   
 	  	  	 tppin100.cfpo  =  tppdm.yeno.yes and   
 	  	  	 tppin100.post  =  tppdm.yeno.yes   
 	  	 selectdo   
 	  	  	 var.tpptc050.trsl  =  tppdm.yeno.yes   
 	  	  	 var.tpptc050.ityp  =  tpprc000.ttys   
 	  	  	 var.tpptc050.ninv  =  tpptc050.ninv   
 	  	 selectempty   
 	  	  	 var.tpptc050.trsl  =  tppdm.yeno.no   
 	  	  	 var.tpptc050.ityp  =  empty.string (1;3)   
 	  	  	 var.tpptc050.ninv  =  0   
 	  	 endselect   
 	 else   
 	  	 var.tpptc050.trsl  =  tppdm.yeno.no   
 	  	 var.tpptc050.ityp  =  empty.string (1;3)   
 	  	 var.tpptc050.ninv  =  0   
 	 endif   
 	 if tpptc050.stin  =  tppdm.stin.deleted then   
 	  	 var.tpptc050.trsl  =  tppdm.yeno.yes   
 	  	 var.tpptc050.ityp  =  tpprc000.ttys   
 	  	 var.tpptc050.ninv  =  tpptc050.ninv   
 	 endif   
 	 select tppdm600.stdt,tppdm600.ncmp   
 	 from tppdm600   
 	 where tppdm600.cprj  =  :tpptc050.cprj   
 	 as set with 1 rows   
 	 selectdo   
 	 endselect   
 	 if tpptc050.codt  <>  0 then   
 	  	 var.tpptc050.rdap  =  utc(tpptc050.codt,0)   
 	  	 var.tpptc050.rdat  =  utc(tpptc050.codt,0)   
 	 else   
 	  	 if tpptc050.stdt  <>  0 then   
 	  	  	 var.tpptc050.rdap  =  utc(tpptc050.stdt,0)   
 	  	  	 var.tpptc050.rdat  =  utc(tpptc050.stdt,0)   
 	  	 else   
 	  	  	 if tppdm600.stdt  <>  0 then   
 	  	  	  	 var.tpptc050.rdap  =  utc(tppdm600.stdt,0)   
 	  	  	  	 var.tpptc050.rdat  =  utc(tppdm600.stdt,0)   
 	  	  	 else   
 	  	  	  	 var.tpptc050.rdap  =  utc(date.num(),0)   
 	  	  	  	 var.tpptc050.rdat  =  utc(date.num(),0)   
 	  	  	 endif   
 	  	 endif   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:050
:SCPAC:tp
:SCMOD:ptc
:SFLNO:050
:ICOD:S
:QURY:START
select tpptc050.*   
from tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:050
:SCPAC:tp
:SCMOD:ptc
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:100
:SCPAC:tp
:SCMOD:ptc
:SFLNO:100
:ICOD:D
:QURY:START
copy.string.with.different.domains(   
 	    	    	    	  tpptc100.seak,   
 	    	    	    	  var.tpptc100.seak,   
 	    	    	    	  "tppdm.seak")   
 if tppdm600.stdt  <>  0 then   
 	    	  var.tpptc100.rdas  =  utc(tppdm600.stdt,0)   
 	    	  var.tpptc100.rdse  =  var.tpptc100.rdas   
 	  else   
 	    	  var.tpptc100.rdas  =  utc(date.num(),0)   
 	    	  var.tpptc100.rdse  =  utc(date.num(),0)   
 	  endif   
 	  on case tppdm600.invm   
 	  case tppdm.invm.unit.rate:   
 	    	  if tpptc100.prin  =  tppdm.prin.project.stage then   
 	    	    	  var.tpptc100.prin  =  2  	    	   | tppdm.prin.no   
 	    	  else   
 	    	    	  var.tpptc100.prin  =  etol(tpptc100.prin)   
 	    	  endif   
 	    	  break   
 	  case tppdm.invm.inst.spec:   
 	    	  var.tpptc100.prin  =  etol(tpptc100.prin)   
 	    	  break   
 	  case tppdm.invm.instalment:   
 	  case tppdm.invm.prime.cost:   
 	    	  var.tpptc100.prin  =  4  	    	   | tppdm.prin.na   
 	    	  break   
 	  endcase   
 	  on case tppdm600.psts   
 	  case tppdm.psts.free:   
 	    	  var.tpptc100.wast  =  1  	    	   | tppdm.wast.free   
 	    	  break   
 	  case tppdm.psts.construction:   
 	    	  var.tpptc100.wast  =  3  	    	   | tppdm.wast.released   
 	    	  break   
 	  case tppdm.psts.finished:   
 	    	  var.tpptc100.wast  =  4  	    	   | tppdm.wast.finished   
 	    	  break   
 	  case tppdm.psts.closed:   
 	    	  var.tpptc100.wast  =  5  	    	   | tppdm.wast.closed   
 	    	  break   
 	  case tppdm.psts.archived:   
 	    	  var.tpptc100.wast  =  5  	    	   | tppdm.wast.closed   
 	    	  break   
 	  endcase   
 	  if tpptc100.stat  =  tpptc.stat.free then   
 	    	  var.tpptc100.wast  =  1  	    	   | tppdm.wast.free   
 	  endif   
 	  if tppdm600.bdmt  =  tppdm.bdmt.production.rate then   
 	    	  var.tpptc100.cuti  =  tpptc100.cuti   
 	  else   
 	    	  var.tpptc100.cuti  =  ""   
 	  endif   
 	  on case var.tpptc100.prin   
 	  case 2:   
 	    	  if tppdm600.invm  =  tppdm.invm.unit.rate or   
 	    	  tppdm600.invm  =  tppdm.invm.instalment or   
 	    	  tppdm600.invm  =  tppdm.invm.prime.cost then   
 	    	    	  var.tpptc100.cspt  =  1  	    	   | tpptc.cspt.direct   
 	    	  endif   
 	    	  if tppdm600.invm  =  tppdm.invm.inst.spec then   
 	    	    	  var.tpptc100.cspt  =  3  	    	   | tpptc.cspt.na   
 	    	  endif   
 	    	  var.tpptc100.gris  =  0   
 	    	  var.tpptc100.pris  =  0.0   
 	    	  var.tpptc100.setl  =  2  	    	    	   | tppdm.yeno.no   
 	    	  break   
 	  case 4:   
 	    	  var.tpptc100.cspt  =  3   
 	    	  var.tpptc100.gris  =  0   
 	    	  var.tpptc100.pris  =  0.0   
 	    	  var.tpptc100.setl  =  2  	    	    	   | tppdm.yeno.no   
 	    	  break   
 	  case 1:   
 	    	  if tppdm600.invm  =  tppdm.invm.unit.rate then   
 	    	    	  var.tpptc100.cspt  =  1   
 	    	  endif   
 	    	  if tppdm600.invm  =  tppdm.invm.inst.spec then   
 	    	    	  var.tpptc100.cspt  =  etol(tpptc100.cspt)   
 	    	  endif   
 	    	  if tppdm600.invm  =  tppdm.invm.instalment or   
 	    	  tppdm600.invm  =  tppdm.invm.prime.cost then   
 	    	    	  var.tpptc100.cspt  =  1  	    	   | tpptc.cspt.direct   
 	    	  endif   
 	    	  var.tpptc100.gris  =  tpptc100.gris   
 	    	  var.tpptc100.pris  =  tpptc100.pris   
 	    	  var.tpptc100.setl  =  etol(tpptc100.setl)   
 	    	  break   
 	  case 3:   
 	    	  if tppdm600.invm  =  tppdm.invm.inst.spec then   
 	    	    	  var.tpptc100.cspt  =  2  	   |   *  tpptc.cspt.indirect   
 	    	  endif   
 	    	  if tppdm600.invm  =  tppdm.invm.unit.rate or   
 	    	  tppdm600.invm  =  tppdm.invm.instalment or   
 	    	  tppdm600.invm  =  tppdm.invm.prime.cost then   
 	    	    	  var.tpptc100.cspt  =  3  	   |   *  tpptc.cspt.na   
 	    	  endif   
 	    	  var.tpptc100.gris  =  tpptc100.gris   
 	    	  var.tpptc100.pris  =  tpptc100.pris   
 	    	  var.tpptc100.setl  =  etol(tpptc100.setl)   
 	    	  break   
 	  endcase   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:100
:SCPAC:tp
:SCMOD:ptc
:SFLNO:100
:ICOD:S
:QURY:START
select tpptc100.*  ,tppdm600.stdt ,tppdm600.invm,tppdm600.psts   
 	  ,tppdm600.bdmt  
from tpptc100,tppdm600
where tppdm600._index1  =  {tpptc100.cprj}
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:100
:SCPAC:tp
:SCMOD:ptc
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:120
:SCPAC:tp
:SCMOD:ptc
:SFLNO:120
:ICOD:D
:QURY:START
var.tpptc120.cprj  =  " "   
 	  get.cost.components (bcorig.tppdm,"", tpptc120.ccco, var.o.errmess)   
 	  var.tpptc120.cprj  =  get.tp.project(tpptc120.cprj)   
 	  var.tpptc120.amoc  =  icom0001.domain.round(   
 	    	    	    	  (tpptc120.quan  *  ( 1  +  tpptc120.scpf  /  100.0 )  *     
 	    	    	    	  tpptc120.pric ),   
 	    	    	    	  "tppdm.aalc")   
 	    	    	    	    	    	    	    	   | # FP10.sn   
 	  if tpptc120.pris  =  0.0 then   
 	    	  var.tpptc120.amos  =  0.0   
 	  else   
 	    	  var.tpptc120.amos  =     
 	    	    	    	  (tpptc120.quan  *     
 	    	    	    	  ( 1  +  tpptc120.scpf  /  100.0 )  *     
 	    	    	    	  tpptc120.pris )   
 	    	  var.tpptc120.amos  =  icom0001.domain.round(   
 	    	    	    	  var.tpptc120.amos,   
 	    	    	    	  "tppdm.aalc",   
 	    	    	    	  comp.ccur)   
 	  endif   
 	  if isspace(tpptc120.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc120.pris  =  0.0   
 	    	  var.tpptc120.amos  =  0.0   
 	    	  var.tpptc120.sacu  =  ""   
 	    	  set.mem(var.tpptc120.rtcs,0)   
 	    	  set.mem(var.tpptc120.rtfs,0)   
 	  else   
 	    	  var.tpptc120.pris  =  tpptc120.pris   
 	    	  var.tpptc120.amos  =  var.tpptc120.amos   
 	    	  var.tpptc120.sacu  =  comp.ccur   
 	    	  var.tpptc120.rtcs(1)  =  1   
 	    	  var.tpptc120.rtcs(2)  =  0   
 	    	  var.tpptc120.rtcs(3)  =  0   
 	    	  var.tpptc120.rtfs(1)  =  1   
 	    	  var.tpptc120.rtfs(2)  =  0   
 	    	  var.tpptc120.rtfs(3)  =  0   
 	  endif   
 	    	    	    	    	    	    	    	   | # FP10.en   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:120
:SCPAC:tp
:SCMOD:ptc
:SFLNO:120
:ICOD:S
:QURY:START
select tpptc120.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050,   
 	  tpptc120
where 	  tpptc120.cprj refers to tppdm600 unref skip   
 and  	  tpptc120.cmbb refers to tpptc050
order by tpptc120._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:120
:SCPAC:tp
:SCMOD:ptc
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:125
:SCPAC:tp
:SCMOD:ptc
:SFLNO:125
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc125.ccco, var.o.errmess)   
 	  var.tpptc125.cprj  =  get.tp.project(tpptc125.cprj)   
 	  var.tpptc125.amoc  =     
 	   	   	   	  (tpptc125.quan  *     
 	   	   	   	  ( 1  +  tpptc125.scpf  /  100.0 )  *     
 	   	   	   	  tpptc125.pric )   
 	  var.tpptc125.amoc  =  icom0001.domain.round(   
 	   	   	   	  var.tpptc125.amoc,   
 	   	   	   	  "tppdm.aalc",   
 	   	   	   	  comp.ccur)   
 	  if tpptc125.pris  =  0.0 then   
 	   	  var.tpptc125.amos  =  0.0   
 	  else   
 	   	  var.tpptc125.amos  =     
 	   	   	   	  (tpptc125.quan  *     
 	   	   	   	  ( 1  +  tpptc125.scpf  /  100.0 )  *     
 	   	   	   	  tpptc125.pris )   
 	   	  var.tpptc125.amos  =  icom0001.domain.round(   
 	   	   	   	  var.tpptc125.amos,   
 	   	   	   	  "tppdm.aalc",   
 	   	   	   	  comp.ccur)   
 	  endif   
 	  if isspace(tpptc125.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc125.pris  =  0.0   
 	   	  var.tpptc125.amos  =  0.0   
 	   	  var.tpptc125.sacu  =  ""   
 	   	  set.mem(var.tpptc125.rtcs,0)   
 	   	  set.mem(var.tpptc125.rtfs,0)   
 	  else   
 	   	  var.tpptc125.pris  =  tpptc125.pris   
 	   	  var.tpptc125.amos  =  var.tpptc125.amos   
 	   	  var.tpptc125.sacu  =  comp.ccur   
 	   	  var.tpptc125.rtcs(1)  =  1   
 	   	  var.tpptc125.rtcs(2)  =  0   
 	   	  var.tpptc125.rtcs(3)  =  0   
 	   	  var.tpptc125.rtfs(1)  =  1   
 	   	  var.tpptc125.rtfs(2)  =  0   
 	   	  var.tpptc125.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:125
:SCPAC:tp
:SCMOD:ptc
:SFLNO:125
:ICOD:S
:QURY:START
select tpptc125.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,   
 	  tpptc125
where 	  tpptc125.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:125
:SCPAC:tp
:SCMOD:ptc
:SFLNO:125
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:130
:SCPAC:tp
:SCMOD:ptc
:SFLNO:130
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc130.ccco, var.o.errmess)   
 	  if save.cprj  <>  tpptc130.cprj then   
 	    	  select  	  tppdm600.stdt   
 	    	  from  	  tppdm600   
 	    	  where  	  tppdm600.cprj  =  :tpptc130.cprj   
 	    	  selectdo   
 	    	  endselect   
 	    	  save.cprj  =  tpptc130.cprj   
 	  endif   
 	  if isspace(tpptc130.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc130.rats  =  0.0   
 	    	  var.tpptc130.amos  =  0.0   
 	    	  var.tpptc130.sacu  =  ""   
 	    	  set.mem(var.tpptc130.rtcs,0)   
 	    	  set.mem(var.tpptc130.rtfs,0)   
 	  else   
 	    	  var.tpptc130.rats  =  tpptc130.rats   
 	    	  var.tpptc130.amos  =  tpptc130.amos   
 	    	  var.tpptc130.sacu  =  comp.ccur   
 	    	  var.tpptc130.rtcs(1)  =  1   
 	    	  var.tpptc130.rtcs(2)  =  0   
 	    	  var.tpptc130.rtcs(3)  =  0   
 	    	  var.tpptc130.rtfs(1)  =  1   
 	    	  var.tpptc130.rtfs(2)  =  0   
 	    	  var.tpptc130.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:130
:SCPAC:tp
:SCMOD:ptc
:SFLNO:130
:ICOD:S
:QURY:START
select  	  tpptc130.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050,   
 	  tpptc130
where 	  tpptc130.cmbb refers to tpptc050
order by tpptc130._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:130
:SCPAC:tp
:SCMOD:ptc
:SFLNO:130
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:135
:SCPAC:tp
:SCMOD:ptc
:SFLNO:135
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc135.ccco, var.o.errmess)   
 	  if save.cprj  <>  tpptc135.cprj then   
 	   	  select  	  tppdm600.stdt   
 	   	  from  	  tppdm600   
 	   	  where  	  tppdm600.cprj  =  :tpptc135.cprj   
 	   	  selectdo   
 	   	  endselect   
 	   	  save.cprj  =  tpptc135.cprj   
 	  endif   
 	  var.tpptc135.amoc  =     
 	   	   	   	  (tpptc135.quan  *  tpptc135.ratc )   
 	  var.tpptc135.amoc  =  icom0001.domain.round(   
 	   	   	   	  var.tpptc135.amoc,   
 	   	   	   	  "tppdm.aalc",   
 	   	   	   	  comp.ccur)   
 	  if tpptc135.rats  =  0.0 then   
 	   	  var.tpptc135.amos  =  0.0   
 	  else   
 	   	  var.tpptc135.amos  =     
 	   	   	   	  (tpptc135.quan  *  tpptc135.rats )   
 	   	  var.tpptc135.amos  =  icom0001.domain.round(   
 	   	   	   	  var.tpptc135.amos,   
 	   	   	   	  "tppdm.aalc",   
 	   	   	   	  comp.ccur)   
 	  endif   
 	  if isspace(tpptc135.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc135.rats  =  0.0   
 	   	  var.tpptc135.amos  =  0.0   
 	   	  var.tpptc135.sacu  =  ""   
 	   	  set.mem(var.tpptc135.rtcs,0)   
 	   	  set.mem(var.tpptc135.rtfs,0)   
 	  else   
 	   	  var.tpptc135.rats  =  tpptc135.rats   
 	   	  var.tpptc135.amos  =  var.tpptc135.amos   
 	   	  var.tpptc135.sacu  =  comp.ccur   
 	   	  var.tpptc135.rtcs(1)  =  1   
 	   	  var.tpptc135.rtcs(2)  =  0   
 	   	  var.tpptc135.rtcs(3)  =  0   
 	   	  var.tpptc135.rtfs(1)  =  1   
 	   	  var.tpptc135.rtfs(2)  =  0   
 	   	  var.tpptc135.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:135
:SCPAC:tp
:SCMOD:ptc
:SFLNO:135
:ICOD:S
:QURY:START
select  	  tpptc135.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,   
 	  tpptc135
where 	  tpptc135.cmbb refers to tpptc050
order by tpptc135._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:135
:SCPAC:tp
:SCMOD:ptc
:SFLNO:135
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:140
:SCPAC:tp
:SCMOD:ptc
:SFLNO:140
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc140.ccco, var.o.errmess)   
 	  if save.cprj  <>  tpptc140.cprj then   
 	    	  select  	  tppdm600.stdt   
 	    	  from  	  tppdm600   
 	    	  where  	  tppdm600.cprj  =  :tpptc140.cprj   
 	    	  selectdo   
 	    	  endselect   
 	    	  save.cprj  =  tpptc140.cprj   
 	  endif   
 	  if isspace(tpptc140.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc140.rats  =  0.0   
 	    	  var.tpptc140.amos  =  0.0   
 	    	  var.tpptc140.sacu  =  ""   
 	    	  var.tpptc140.sacu  =  comp.ccur |  *  This line should be   
 	    	   |  *  removed when tpptc140.sacu is made not  -  mandatory.   
 	    	  set.mem(var.tpptc140.rtcs,0)   
 	    	  set.mem(var.tpptc140.rtfs,0)   
 	  else   
 	    	  var.tpptc140.rats  =  tpptc140.rats   
 	    	  var.tpptc140.amos  =  tpptc140.amos   
 	    	  var.tpptc140.sacu  =  comp.ccur   
 	    	  var.tpptc140.rtcs(1)  =  1   
 	    	  var.tpptc140.rtcs(2)  =  0   
 	    	  var.tpptc140.rtcs(3)  =  0   
 	    	  var.tpptc140.rtfs(1)  =  1   
 	    	  var.tpptc140.rtfs(2)  =  0   
 	    	  var.tpptc140.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:140
:SCPAC:tp
:SCMOD:ptc
:SFLNO:140
:ICOD:S
:QURY:START
select  	  tpptc140.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050,   
 	  tpptc140
where 	  tpptc140.cmbb refers to tpptc050
order by tpptc140._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:140
:SCPAC:tp
:SCMOD:ptc
:SFLNO:140
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:145
:SCPAC:tp
:SCMOD:ptc
:SFLNO:145
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc145.ccco, var.o.errmess)   
 	  if isspace(tpptc145.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc145.rats  =  0.0   
 	   	  var.tpptc145.amos  =  0.0   
 	   	  var.tpptc145.sacu  =  ""   
 	   	  set.mem(var.tpptc145.rtcs,0)   
 	   	  set.mem(var.tpptc145.rtfs,0)   
 	  else   
 	   	  var.tpptc145.rats  =  tpptc145.rats   
 	   	  var.tpptc145.amos  =  tpptc145.amos   
 	   	  var.tpptc145.sacu  =  comp.ccur   
 	   	  var.tpptc145.rtcs(1)  =  1   
 	   	  var.tpptc145.rtcs(2)  =  0   
 	   	  var.tpptc145.rtcs(3)  =  0   
 	   	  var.tpptc145.rtfs(1)  =  1   
 	   	  var.tpptc145.rtfs(2)  =  0   
 	   	  var.tpptc145.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:145
:SCPAC:tp
:SCMOD:ptc
:SFLNO:145
:ICOD:S
:QURY:START
select  	  tpptc145.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,   
 	  tpptc145
where 	  tpptc145.cmbb refers to tpptc050
order by tpptc145._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:145
:SCPAC:tp
:SCMOD:ptc
:SFLNO:145
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:150
:SCPAC:tp
:SCMOD:ptc
:SFLNO:150
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc150.ccco, var.o.errmess)   
 	  if save.cprj  <>  tpptc150.cprj then   
 	    	  select  	  tppdm600.stdt   
 	    	  from  	  tppdm600   
 	    	  where  	  tppdm600.cprj  =  :tpptc150.cprj   
 	    	  selectdo   
 	    	  endselect   
 	    	  save.cprj  =  tpptc150.cprj   
 	  endif   
 	  if isspace(tpptc150.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc150.pris  =  0.0   
 	    	  var.tpptc150.amos  =  0.0   
 	    	  var.tpptc150.sacu  =  ""   
 	    	  set.mem(var.tpptc150.rtcs,0)   
 	    	  set.mem(var.tpptc150.rtfs,0)   
 	  else   
 	    	  var.tpptc150.pris  =  tpptc150.pris   
 	    	  var.tpptc150.amos  =  tpptc150.amos   
 	    	  var.tpptc150.sacu  =  comp.ccur   
 	    	  var.tpptc150.rtcs(1)  =  1   
 	    	  var.tpptc150.rtcs(2)  =  0   
 	    	  var.tpptc150.rtcs(3)  =  0   
 	    	  var.tpptc150.rtfs(1)  =  1   
 	    	  var.tpptc150.rtfs(2)  =  0   
 	    	  var.tpptc150.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:150
:SCPAC:tp
:SCMOD:ptc
:SFLNO:150
:ICOD:S
:QURY:START
select tpptc150.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050,   
 	  tpptc150
where 	  tpptc150.cmbb refers to tpptc050
order by tpptc150._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:150
:SCPAC:tp
:SCMOD:ptc
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:155
:SCPAC:tp
:SCMOD:ptc
:SFLNO:155
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc155.ccco, var.o.errmess)   
 	  if isspace(tpptc155.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc155.pris  =  0.0   
 	   	  var.tpptc155.amos  =  0.0   
 	   	  var.tpptc155.sacu  =  ""   
 	   	  set.mem(var.tpptc155.rtcs,0)   
 	   	  set.mem(var.tpptc155.rtfs,0)   
 	  else   
 	   	  var.tpptc155.pris  =  tpptc155.pris   
 	   	  var.tpptc155.amos  =  tpptc155.amos   
 	   	  var.tpptc155.sacu  =  comp.ccur   
 	   	  var.tpptc155.rtcs(1)  =  1   
 	   	  var.tpptc155.rtcs(2)  =  0   
 	   	  var.tpptc155.rtcs(3)  =  0   
 	   	  var.tpptc155.rtfs(1)  =  1   
 	   	  var.tpptc155.rtfs(2)  =  0   
 	   	  var.tpptc155.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:155
:SCPAC:tp
:SCMOD:ptc
:SFLNO:155
:ICOD:S
:QURY:START
select  	  tpptc155.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,   
 	  tpptc155
where 	  tpptc155.cmbb refers to tpptc050
order by tpptc155._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:155
:SCPAC:tp
:SCMOD:ptc
:SFLNO:155
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:160
:SCPAC:tp
:SCMOD:ptc
:SFLNO:160
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc160.ccco, var.o.errmess)   
 	  if save.cprj  <>  tpptc160.cprj then   
 	    	  select  	  tppdm600.stdt   
 	    	  from  	  tppdm600   
 	    	  where  	  tppdm600.cprj  =  :tpptc160.cprj   
 	    	  selectdo   
 	    	  endselect   
 	    	  save.cprj  =  tpptc160.cprj   
 	  endif   
 	  if isspace(tpptc160.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc160.pris  =  0.0   
 	    	  var.tpptc160.amos  =  0.0   
 	    	  var.tpptc160.sacu  =  ""   
 	    	  set.mem(var.tpptc160.rtcs,0)   
 	    	  set.mem(var.tpptc160.rtfs,0)   
 	  else   
 	    	  var.tpptc160.pris  =  tpptc160.pris   
 	    	  var.tpptc160.amos  =  tpptc160.amos   
 	    	  var.tpptc160.sacu  =  comp.ccur   
 	    	  var.tpptc160.rtcs(1)  =  1   
 	    	  var.tpptc160.rtcs(2)  =  0   
 	    	  var.tpptc160.rtcs(3)  =  0   
 	    	  var.tpptc160.rtfs(1)  =  1   
 	    	  var.tpptc160.rtfs(2)  =  0   
 	    	  var.tpptc160.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:160
:SCPAC:tp
:SCMOD:ptc
:SFLNO:160
:ICOD:S
:QURY:START
select  	  tpptc160.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050,   
 	  tpptc160
where 	  tpptc160.cmbb refers to tpptc050
order by tpptc160._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:160
:SCPAC:tp
:SCMOD:ptc
:SFLNO:160
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:165
:SCPAC:tp
:SCMOD:ptc
:SFLNO:165
:ICOD:D
:QURY:START
	  get.cost.components (bcorig.tppdm,"", tpptc165.ccco, var.o.errmess)   
 	  if isspace(tpptc165.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc165.pris  =  0.0   
 	   	  var.tpptc165.amos  =  0.0   
 	   	  var.tpptc165.sacu  =  ""   
 	   	  set.mem(var.tpptc165.rtcs,0)   
 	   	  set.mem(var.tpptc165.rtfs,0)   
 	  else   
 	   	  var.tpptc165.pris  =  tpptc165.pris   
 	   	  var.tpptc165.amos  =  tpptc165.amos   
 	   	  var.tpptc165.sacu  =  comp.ccur   
 	   	  var.tpptc165.rtcs(1)  =  1   
 	   	  var.tpptc165.rtcs(2)  =  0   
 	   	  var.tpptc165.rtcs(3)  =  0   
 	   	  var.tpptc165.rtfs(1)  =  1   
 	   	  var.tpptc165.rtfs(2)  =  0   
 	   	  var.tpptc165.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:165
:SCPAC:tp
:SCMOD:ptc
:SFLNO:165
:ICOD:S
:QURY:START
select  	  tpptc165.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,   
 	  tpptc165
where 	  tpptc165.cmbb refers to tpptc050
order by tpptc165._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:165
:SCPAC:tp
:SCMOD:ptc
:SFLNO:165
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:225
:SCPAC:tp
:SCMOD:ptc
:SFLNO:225
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc225.ccco, var.o.errmess)   
 	  var.tpptc225.cprj  =  tpptc225.cprj   
 	  var.tpptc225.amoc  =    
 	    	    	    	  (tpptc225.quan  *    
 	    	    	    	  ( 1  +  tpptc225.scpf  /  100.0 )  *    
 	    	    	    	  tpptc225.pric )   
 	  var.tpptc225.amoc  =  icom0001.domain.round(   
 	    	    	    	  var.tpptc225.amoc,   
 	    	    	    	  "tppdm.aalc",   
 	    	    	    	  comp.ccur)   
 	  if tpptc225.pris  =  0.0 then   
 	    	  var.tpptc225.amos  =  0.0   
 	  else   
 	    	  var.tpptc225.amos  =    
 	    	    	    	  (tpptc225.quan  *    
 	    	    	    	  ( 1  +  tpptc225.scpf  /  100.0 )  *    
 	    	    	    	  tpptc225.pris )   
 	    	  var.tpptc225.amos  =  icom0001.domain.round(   
 	    	    	    	  var.tpptc225.amos,   
 	    	    	    	  "tppdm.aalc",   
 	    	    	    	  comp.ccur)   
 	  endif   
 	  select tpptc220.*    
 	  from tpptc220   
 	  where  	  tpptc220._index1  =  {:tpptc225.cprj, :tpptc225.cpla, :tpptc225.cact, :tpptc225.sern}   
 	  selectdo   
 	    	  var.tppdm.date.o.stdt  =  0   
 	    	  var.tppdm.date.o.fidt  =  0   
 	    	  var.tppdm.dprt.o.stdp  =  0   
 	    	  var.tppdm.dprt.o.fidp  =  0   
 	    	  select tppss200.*    
 	    	  from tppss200   
 	    	  where tppss200._index1  =  {:tpptc220.cprj, :tpptc220.cpla, :tpptc220.cact}   
 	    	  selectdo   
 	    	    	  select tppss010.*    
 	    	    	  from tppss010   
 	    	    	  where tppss010._index1  =  {:tpptc220.cprj, :tpptc220.cpla}   
 	    	    	  selectdo   
 	    	    	    	  if tpptc220.rsta  <>  0 or tpptc220.rfin  <>  100 then   
 	    	    	    	    	  if tppss200.capt  =  tppdm.cotp.tasks or tppss200.capt  =  tppdm.cotp.equipment then   
 	    	    	    	    	    	  itppss0032.determine.calendar.level.for.activity (tppss200.cprj, tppss200.cpla,tppss200.cact,tppss200.capt, tppss010.rslv, var.tppss.cltp.l.cltp,var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ)   
 	    	    	    	    	  else   
 	    	    	    	    	    	  var.tppss.cltp.l.cltp  =  tppss.cltp.project.cal   
 	    	    	    	    	  endif   
 	    	    	    	  endif   
 	    	    	    	  if tpptc220.rsta  =  0 then   
 	    	    	    	    	  var.tppdm.date.o.stdt  =  tppss200.psdt   
 	    	    	    	    	  var.tppdm.dprt.o.stdp  =  tppss200.psdp   
 	    	    	    	  else   
 	    	    	    	    	  var.tppdm.pltm.l.duration  =  (tpptc220.rsta  /  100.0)  *  tppss200.adur   
 	    	    	    	    	  itppss0030.plan.forward (tppdm.stfi.start, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp,  	  var.tppdm.pltm.l.duration, var.tppdm.date.o.stdt, var.tppdm.dprt.o.stdp, var.tppdm.s080.l.mess)   
 	    	    	    	  endif   
 	    	    	    	  if tpptc220.rfin  =  100 then   
 	    	    	    	    	  var.tppdm.date.o.fidt  =  tppss200.pfdt   
 	    	    	    	    	  var.tppdm.dprt.o.fidp  =  tppss200.pfdp   
 	    	    	    	  else   
 	    	    	    	    	  var.tppdm.pltm.l.duration  =  (tpptc220.rfin  /  100.0)  *    	  tppss200.adur   
 	    	    	    	    	  itppss0030.plan.forward (tppdm.stfi.finish, var.tppss.cltp.l.cltp,tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp,  	  var.tppdm.pltm.l.duration, var.tppdm.date.o.fidt, var.tppdm.dprt.o.fidp, var.tppdm.s080.l.mess)   
 	    	    	    	  endif   
 	    	    	  endselect   
 	    	  endselect   
 	    	  if var.tppdm.dprt.o.stdp  >=  0.5 then   
 	    	    	  var.tppdm.date.o.stdt  =  var.tppdm.date.o.stdt  +  1   
 	    	  endif   
 	    	  if var.tppdm.dprt.o.fidp  >=  0.5 then   
 	    	    	  var.tppdm.date.o.fidt  =  var.tppdm.date.o.fidt  +  1   
 	    	  endif   
 	  endselect   
 	  if tppss200.psdt  <>  0 then   
 	    	  var.tpptc225.btdt  =  utc(tppss200.psdt,0)   
 	  else   
 	    	  if tppss010.stdt  <>  0 then   
 	    	    	  var.tpptc225.btdt  =  utc (tppss010.stdt,0)   
 	    	  else   
 	    	    	  if tppdm600.stdt  <>  0 then   
 	    	    	    	  var.tpptc225.btdt  =  utc (tppdm600.stdt,0)   
 	    	    	  else   
 	    	    	    	  var.tpptc225.btdt  =  utc (date.num () ,0)   
 	    	    	  endif   
 	    	  endif   
 	  endif   
 	  if isspace(tpptc225.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc225.pris  =  0.0   
 	    	  var.tpptc225.amos  =  0.0   
 	    	  var.tpptc225.sacu  =  ""   
 	    	  set.mem(var.tpptc225.rtcs,0)   
 	    	  set.mem(var.tpptc225.rtfs,0)   
 	  else   
 	    	  var.tpptc225.pris  =  tpptc225.pris   
 	    	  var.tpptc225.amos  =  var.tpptc225.amos   
 	    	  var.tpptc225.sacu  =  comp.ccur   
 	    	  var.tpptc225.rtcs(1)  =  1   
 	    	  var.tpptc225.rtcs(2)  =  0   
 	    	  var.tpptc225.rtcs(3)  =  0   
 	    	  var.tpptc225.rtfs(1)  =  1   
 	    	  var.tpptc225.rtfs(2)  =  0   
 	    	  var.tpptc225.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:225
:SCPAC:tp
:SCMOD:ptc
:SFLNO:225
:ICOD:S
:QURY:START
select tpptc225.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050, tpptc225
where 	  tpptc225.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:225
:SCPAC:tp
:SCMOD:ptc
:SFLNO:225
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:235
:SCPAC:tp
:SCMOD:ptc
:SFLNO:235
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc235.ccco, var.o.errmess)   
 	  var.tppdm.date.o.fidt  =  0   
 	  var.tppdm.date.o.stdt  =  0   
 	  var.tppdm.dprt.o.fidp  =  0   
 	  var.tppdm.dprt.o.stdp  =  0   
 	  select  	  tpptc230.*     
 	  from  	  tpptc230   
 	  where  	  tpptc230._index1  =  {:tpptc235.cprj, :tpptc235.cpla, :tpptc235.cact, :tpptc235.sern}   
 	  selectdo   
 	   	  select tppss200.*     
 	   	  from tppss200   
 	   	  where tppss200._index1  =  {:tpptc230.cprj, :tpptc230.cpla, :tpptc230.cact}   
 	   	  selectdo   
 	   	   	  select tppss010.*     
 	   	   	  from tppss010   
 	   	   	  where tppss010._index1  =  {:tpptc230.cprj, :tpptc230.cpla}   
 	   	   	  selectdo   
 	   	   	   	  if tpptc230.rsta  <>  0 or tpptc230.rfin  <>  100 then   
 	   	   	   	   	  if tppss200.capt  =  tppdm.cotp.tasks or tppss200.capt  =  tppdm.cotp.equipment then   
 	   	   	   	   	   	  itppss0032.determine.calendar.level.for.activity (tppss200.cprj, tppss200.cpla, tppss200.cact, tppss200.capt, tppss010.rslv, var.tppss.cltp.l.cltp,  	  var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ)   
 	   	   	   	   	  else   
 	   	   	   	   	   	  var.tppss.cltp.l.cltp  =  tppss.cltp.project.cal   
 	   	   	   	   	  endif   
 	   	   	   	  endif   
 	   	   	   	  if tpptc230.rsta  =  0 then   
 	   	   	   	   	  var.tppdm.date.o.stdt  =  tppss200.psdt   
 	   	   	   	   	  var.tppdm.dprt.o.stdp  =  tppss200.psdp   
 	   	   	   	  else   
 	   	   	   	   	  var.tppdm.pltm.l.duration  =  (tpptc230.rsta  /  100.0)  *  tppss200.adur   
 	   	   	   	   	  itppss0030.plan.forward (tppdm.stfi.start,  	  var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp,  	  var.tppdm.pltm.l.duration, var.tppdm.date.o.stdt, var.tppdm.dprt.o.stdp, var.tppdm.s080.l.mess)   
 	   	   	   	  endif   
 	   	   	   	  if tpptc230.rfin  =  100 then   
 	   	   	   	   	  var.tppdm.date.o.fidt  =  tppss200.pfdt   
 	   	   	   	   	  var.tppdm.dprt.o.fidp  =  tppss200.pfdp   
 	   	   	   	  else   
 	   	   	   	   	  var.tppdm.pltm.l.duration  =  (tpptc230.rfin  /  100.0)  *  tppss200.adur   
 	   	   	   	   	  itppss0030.plan.forward (tppdm.stfi.finish, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp,  	  var.tppdm.pltm.l.duration, var.tppdm.date.o.fidt, var.tppdm.dprt.o.fidp, var.tppdm.s080.l.mess)   
 	   	   	   	  endif   
 	   	   	  endselect   
 	   	  endselect   
 	   	  if var.tppdm.dprt.o.stdp  >=  0.5 then   
 	   	  var.tppdm.date.o.stdt  =  var.tppdm.date.o.stdt  +  1   
 	   	  endif   
 	   	  if var.tppdm.dprt.o.fidp  >=  0.5 then   
 	   	  var.tppdm.date.o.fidt  =  var.tppdm.date.o.fidt  +  1   
 	   	  endif   
 	  endselect   
 	  if tppss200.psdt  <>  0 then   
 	   	  var.tpptc235.btdt  =  utc(tppss200.psdt,0)   
 	  else   
 	   	  if tppss010.stdt  <>  0 then   
 	   	   	  var.tpptc235.btdt  =  utc (tppss010.stdt,0)   
 	   	  else   
 	   	   	  if tppdm600.stdt  <>  0 then   
 	   	   	   	  var.tpptc235.btdt  =  utc (tppdm600.stdt,0)   
 	   	   	  else   
 	   	   	   	  var.tpptc235.btdt  =  utc (date.num () ,0)   
 	   	   	  endif   
 	   	  endif   
 	  endif   
 	  if isspace(tpptc235.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc235.rats  =  0.0   
 	   	  var.tpptc235.amos  =  0.0   
 	   	  var.tpptc235.sacu  =  ""   
 	   	  set.mem(var.tpptc235.rtcs,0)   
 	   	  set.mem(var.tpptc235.rtfs,0)   
 	  else   
 	   	  var.tpptc235.rats  =  tpptc235.rats   
 	   	  var.tpptc235.amos  =  tpptc235.amos   
 	   	  var.tpptc235.sacu  =  comp.ccur   
 	   	  var.tpptc235.rtcs(1)  =  1   
 	   	  var.tpptc235.rtcs(2)  =  0   
 	   	  var.tpptc235.rtcs(3)  =  0   
 	   	  var.tpptc235.rtfs(1)  =  1   
 	   	  var.tpptc235.rtfs(2)  =  0   
 	   	  var.tpptc235.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:235
:SCPAC:tp
:SCMOD:ptc
:SFLNO:235
:ICOD:S
:QURY:START
select  	  tpptc235.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,tpptc235
where 	  tpptc235.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:235
:SCPAC:tp
:SCMOD:ptc
:SFLNO:235
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:245
:SCPAC:tp
:SCMOD:ptc
:SFLNO:245
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc245.ccco, var.o.errmess)   
 	  var.tppdm.date.o.fidt  =  0   
 	  var.tppdm.dprt.o.fidp  =  0   
 	  var.tppdm.date.o.stdt  =  0   
 	  var.tppdm.dprt.o.stdp  =  0   
 	  select tpptc240.*     
 	  from  	  tpptc240   
 	  where  	  tpptc240._index1  =  {:tpptc245.cprj, :tpptc245.cpla, :tpptc245.cact, :tpptc245.sern}   
 	  selectdo   
 	    	  select tppss200.*     
 	    	  from tppss200   
 	    	  where tppss200._index1  =  {:tpptc240.cprj, :tpptc240.cpla, :tpptc240.cact}   
 	    	  selectdo   
 	    	    	  select tppss010.*     
 	    	    	  from tppss010   
 	    	    	  where tppss010._index1  =  {:tpptc240.cprj, :tpptc240.cpla}   
 	    	    	  selectdo   
 	    	    	    	  if tpptc240.rsta  <>  0 or tpptc240.rfin  <>  100 then   
 	    	    	    	    	  if tppss200.capt  =  tppdm.cotp.tasks or tppss200.capt  =  tppdm.cotp.equipment then   
 	    	    	    	    	    	  itppss0032.determine.calendar.level.for.activity (tppss200.cprj, tppss200.cpla, tppss200.cact, tppss200.capt, tppss010.rslv, var.tppss.cltp.l.cltp, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ)   
 	    	    	    	    	  else   
 	    	    	    	    	  var.tppss.cltp.l.cltp  =  tppss.cltp.project.cal   
 	    	    	    	    	  endif   
 	    	    	    	  endif   
 	    	    	    	  if tpptc240.rsta  =  0 then   
 	    	    	    	    	  var.tppdm.date.o.stdt  =  tppss200.psdt   
 	    	    	    	    	  var.tppdm.dprt.o.stdp  =  tppss200.psdp   
 	    	    	    	  else   
 	    	    	    	    	  var.tppdm.pltm.l.duration  =  (tpptc240.rsta  /  100.0)  *  tppss200.adur   
 	    	    	    	    	  itppss0030.plan.forward (tppdm.stfi.start,  	  var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.stdt, var.tppdm.dprt.o.stdp, var.tppdm.s080.l.mess)   
 	    	    	    	  endif   
 	    	    	    	  if tpptc240.rfin  =  100 then   
 	    	    	    	    	  var.tppdm.date.o.fidt  =  tppss200.pfdt   
 	    	    	    	    	  var.tppdm.dprt.o.fidp  =  tppss200.pfdp   
 	    	    	    	  else   
 	    	    	    	    	  var.tppdm.pltm.l.duration  =  (tpptc240.rfin  /  100.0)  *  tppss200.adur   
 	    	    	    	    	  itppss0030.plan.forward (tppdm.stfi.finish, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ,  	  tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.fidt, var.tppdm.dprt.o.fidp, var.tppdm.s080.l.mess)   
 	    	    	    	  endif   
 	    	    	  endselect   
 	    	  endselect   
 	    	  if var.tppdm.dprt.o.stdp  >=  0.5 then   
 	    	    	  var.tppdm.date.o.stdt  =  var.tppdm.date.o.stdt  +  1   
 	    	  endif   
 	    	  if var.tppdm.dprt.o.fidp  >=  0.5 then   
 	    	  var.tppdm.date.o.fidt  =  var.tppdm.date.o.fidt  +  1   
 	    	  endif   
 	  endselect   
 	  if tppss200.psdt  <>  0 then   
 	    	  var.tpptc245.btdt  =  utc(tppss200.psdt,0)   
 	  else   
 	    	  if tppss010.stdt  <>  0 then   
 	    	    	  var.tpptc245.btdt  =  utc (tppss010.stdt,0)   
 	    	  else   
 	    	    	  if tppdm600.stdt  <>  0 then   
 	    	    	    	  var.tpptc245.btdt  =  utc (tppdm600.stdt,0)   
 	    	    	  else   
 	    	    	    	  var.tpptc245.btdt  =  utc (date.num () ,0)   
 	    	    	  endif   
 	    	  endif   
 	  endif   
 	  if isspace(tpptc245.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc245.rats  =  0.0   
 	    	  var.tpptc245.amos  =  0.0   
 	    	  var.tpptc245.sacu  =  ""   
 	    	  set.mem(var.tpptc245.rtcs,0)   
 	    	  set.mem(var.tpptc245.rtfs,0)   
 	  else   
 	    	  var.tpptc245.rats  =  tpptc245.rats   
 	    	  var.tpptc245.amos  =  tpptc245.amos   
 	    	  var.tpptc245.sacu  =  comp.ccur   
 	    	  var.tpptc245.rtcs(1)  =  1   
 	    	  var.tpptc245.rtcs(2)  =  0   
 	    	  var.tpptc245.rtcs(3)  =  0   
 	    	  var.tpptc245.rtfs(1)  =  1   
 	    	  var.tpptc245.rtfs(2)  =  0   
 	    	  var.tpptc245.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:245
:SCPAC:tp
:SCMOD:ptc
:SFLNO:245
:ICOD:S
:QURY:START
select  	  tpptc245.*  ,tppdm600.stdt,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc245,tppdm600,   
 	  tpptc050
where 	  tpptc245.cprj refers to tppdm600 unref skip   
 and  	  tpptc245.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:245
:SCPAC:tp
:SCMOD:ptc
:SFLNO:245
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:250
:SCPAC:tp
:SCMOD:ptc
:SFLNO:250
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc250.ccco, var.o.errmess)   
 	  select tppss200.*     
 	  from tppss200   
 	  where tppss200._index1  =  {:tpptc250.cprj, :tpptc250.cpla, :tpptc250.cact}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  select tppss010.*     
 	   	  from tppss010   
 	   	  where tppss010._index1  =  {:tpptc250.cprj, :tpptc250.cpla}   
 	   	  selectdo   
 	   	   	  if tppss200.adur  =  0 or tppss200.psdt  =  0 then   
 	   	   	   	  if tppss200.psdt  <>  0 then   
 	   	   	   	   	  var.lng.stdp  =  var.lng.start  +  ((tppss200.psdp  *  var.dbl.duration)  *  60  *  60)   
 	   	   	   	   	  var.tpptc250.rsta  =  utc(tppss200.psdt,var.lng.stdp)   
 	   	   	   	   	  var.tpptc250.rfin  =  var.tpptc250.rsta   
 	   	   	   	  else   
 	   	   	   	   	  var.tpptc250.rsta  =  utc(0,0)   
 	   	   	   	   	  var.tpptc250.rfin  =  utc(0,0)   
 	   	   	   	  endif   
 	   	   	  else   
 	   	   	   	  if tpptc250.rsta  <>  0 or tpptc250.rfin  <>  100 then   
 	   	   	   	   	  if tppss200.capt  =  tppdm.cotp.tasks or tppss200.capt  =  tppdm.cotp.equipment then   
 	   	   	   	   	   	  itppss0032.determine.calendar.level.for.activity (tppss200.cprj, tppss200.cpla, tppss200.cact, tppss200.capt, tppss010.rslv, var.tppss.cltp.l.cltp, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ)   
 	   	   	   	   	  else   
 	   	   	   	   	   	  var.tppss.cltp.l.cltp  =  tppss.cltp.project.cal   
 	   	   	   	   	  endif   
 	   	   	   	  endif   
 	   	   	   	  if tpptc250.rsta  =  0 then   
 	   	   	   	   	  var.tppdm.date.o.stdt  =  tppss200.psdt   
 	   	   	   	   	  var.tppdm.dprt.o.stdp  =  tppss200.psdp   
 	   	   	   	  else   
 	   	   	   	   	  var.tppdm.pltm.l.duration  =  (tpptc250.rsta  /  100.0)  *  tppss200.adur   
 	   	   	   	   	  itppss0030.plan.forward (tppdm.stfi.start, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.stdt, var.tppdm.dprt.o.stdp, var.tppdm.s080.l.mess)   
 	   	   	   	  endif   
 	   	   	   	  if tpptc250.rfin  =  100 then   
 	   	   	   	   	  var.tppdm.dprt.o.dprt  =  tppss200.pfdt   
 	   	   	   	   	  var.tppdm.dprt.o.fidtp  =  tppss200.pfdp   
 	   	   	   	  else   
 	   	   	   	   	  var.tppdm.pltm.l.duration  =  (tpptc250.rfin  /  100.0)  *  tppss200.adur   
 	   	   	   	   	  itppss0030.plan.forward (tppdm.stfi.finish, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.dprt.o.dprt, var.tppdm.dprt.o.fidtp, var.tppdm.s080.l.mess)   
 	   	   	   	  endif   
 	   	   	   	  var.lng.stdp  =  var.lng.start  +  ((var.tppdm.dprt.o.stdp  *  var.dbl.duration)  *  60  *  60)   
 	   	   	   	  var.lng.fidp  =  var.lng.start  +  ((var.tppdm.dprt.o.fidtp  *  var.dbl.duration)  *  60  *  60)   
 	   	   	   	  if (var.tppdm.date.o.stdt  >  var.tppdm.dprt.o.dprt) then   
 	   	   	   	   	  var.tpptc250.rsta  =  utc (var.tppdm.date.o.stdt,var.lng.stdp)   
 	   	   	   	   	  var.tpptc250.rfin  =  utc (var.tppdm.date.o.stdt,var.lng.fidp)   
 	   	   	   	  else   
 	   	   	   	   	  var.tpptc250.rsta  =  utc (var.tppdm.date.o.stdt,var.lng.stdp)   
 	   	   	   	   	  var.tpptc250.rfin  =  utc (var.tppdm.dprt.o.dprt,var.lng.fidp)   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	  endselect   
 	  endselect   
 	  if tppss200.psdt  <>  0 then   
 	   	  var.tpptc250.btdt  =  utc(tppss200.psdt,0)   
 	  else   
 	   	  if tppss010.stdt  <>  0 then   
 	   	   	  var.tpptc250.btdt  =  utc(tppss010.stdt,0)   
 	   	  else   
 	   	   	  if tppdm600.stdt  <>  0 then   
 	   	   	   	  var.tpptc250.btdt  =  utc (tppdm600.stdt,0)   
 	   	   	  else   
 	   	   	   	  var.tpptc250.btdt  =  utc (date.num () ,0)   
 	   	   	  endif   
 	   	  endif   
 	  endif   
 	  reft.csub  =  read.subcontracting(   
 	   	   	   	  tpptc250.csub,   
 	   	   	   	  tpptc250.cprj,   
 	   	   	   	  desc.csub,   
 	   	   	   	  2,1,0) |#Unit.type.n   
 | 	   	   	   	  1,1,0) |#Unit.type.o   
 	  if reft.csub  =  tppdm.reft.standard then   
 	   	  csub.dsbc  	    =  tppdm035.dsbc   
 	  else   
 	   	  csub.dsbc  	    =  tppdm635.dsbc   
 	  endif   
 	  if csub.dsbc  =  tppdm.dsbc.quantity then   
 	   	  var.tpptc250.qutm  =  0   
 	   	  var.tpptc250.quan  =  tpptc250.quan   
 	   	  var.tpptc250.cuni  =  tpptc250.cuni   
 	   	  var.tpptc250.cuti  =  ""   
 	  else   
 	   	  var.tpptc250.quan  =  0   
 	   	  var.tpptc250.cuni  =  ""   
 	   	  var.tpptc250.qutm  =  tpptc250.qutm   
 	   	  var.tpptc250.cuti  =  tpptc250.cuti   
 	  endif   
 	  if isspace(tpptc250.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc250.pris  =  0.0   
 	   	  var.tpptc250.amos  =  0.0   
 	   	  var.tpptc250.sacu  =  ""   
 	   	  set.mem(var.tpptc250.rtcs,0)   
 	   	  set.mem(var.tpptc250.rtfs,0)   
 	  else   
 	   	  var.tpptc250.pris  =  tpptc250.pris   
 	   	  var.tpptc250.amos  =  tpptc250.amos   
 	   	  var.tpptc250.sacu  =  comp.ccur   
 	   	  var.tpptc250.rtcs(1)  =  1   
 	   	  var.tpptc250.rtcs(2)  =  0   
 	   	  var.tpptc250.rtcs(3)  =  0   
 	   	  var.tpptc250.rtfs(1)  =  1   
 	   	  var.tpptc250.rtfs(2)  =  0   
 	   	  var.tpptc250.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:250
:SCPAC:tp
:SCMOD:ptc
:SFLNO:250
:ICOD:S
:QURY:START
select tpptc250.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050, tpptc250
where 	  tpptc250.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:250
:SCPAC:tp
:SCMOD:ptc
:SFLNO:250
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:255
:SCPAC:tp
:SCMOD:ptc
:SFLNO:255
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc255.ccco, var.o.errmess)   
 	  var.tppdm.date.o.fidt  =  0   
 	  var.tppdm.date.o.stdt  =  0   
 	  var.tppdm.dprt.o.fidp  =  0   
 	  var.tppdm.dprt.o.stdp  =  0   
 	  select  	  tpptc250.*     
 	  from  	  tpptc250   
 	  where  	  tpptc250._index1  =  {:tpptc255.cprj, :tpptc255.cpla, :tpptc255.cact, :tpptc255.sern}   
 	  selectdo   
 	   	  select tppss200.*     
 	   	  from tppss200   
 	   	  where tppss200._index1  =  {:tpptc250.cprj, :tpptc250.cpla, :tpptc250.cact}   
 	   	  selectdo   
 	   	   	  select tppss010.*     
 	   	   	  from tppss010   
 	   	   	  where tppss010._index1  =  {:tpptc250.cprj, :tpptc250.cpla}   
 	   	   	  selectdo   
 	   	   	   	  if tpptc250.rsta  <>  0 or tpptc250.rfin  <>  100 then   
 	   	   	   	   	  if tppss200.capt  =  tppdm.cotp.tasks or tppss200.capt  =  tppdm.cotp.equipment then   
 	   	   	   	   	   	  itppss0032.determine.calendar.level.for.activity (tppss200.cprj, tppss200.cpla, tppss200.cact, tppss200.capt, tppss010.rslv, var.tppss.cltp.l.cltp, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ)   
 	   	   	   	   	  else   
 	   	   	   	   	   	  var.tppss.cltp.l.cltp  =  tppss.cltp.project.cal   
 	   	   	   	   	  endif   
 	   	   	   	  endif   
 	   	   	   	  if tpptc250.rsta  =  0 then   
 	   	   	   	   	  var.tppdm.date.o.stdt  =  tppss200.psdt   
 	   	   	   	   	  var.tppdm.dprt.o.stdp  =  tppss200.psdp   
 	   	   	   	  else   
 	   	   	   	   	  var.tppdm.pltm.l.duration  =  (tpptc250.rsta  /  100.0)  *  tppss200.adur   
 	   	   	   	   	  itppss0030.plan.forward (tppdm.stfi.start,  	  var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.stdt, var.tppdm.dprt.o.stdp, var.tppdm.s080.l.mess)   
 	   	   	   	  endif   
 	   	   	   	  if tpptc250.rfin  =  100 then   
 	   	   	   	   	  var.tppdm.date.o.fidt  =  tppss200.pfdt   
 	   	   	   	   	  var.tppdm.dprt.o.fidp  =  tppss200.pfdp   
 	   	   	   	  else   
 	   	   	   	   	  var.tppdm.pltm.l.duration  =  (tpptc250.rfin  /  100.0)  *  tppss200.adur   
 	   	   	   	   	  itppss0030.plan.forward (tppdm.stfi.finish, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.fidt, var.tppdm.dprt.o.fidp, var.tppdm.s080.l.mess)   
 	   	   	   	  endif   
 	   	   	  endselect   
 	   	  endselect   
 	   	  if var.tppdm.dprt.o.stdp  >=  0.5 then   
 	   	  var.tppdm.date.o.stdt  =  var.tppdm.date.o.stdt  +  1   
 	   	  endif   
 	   	  if var.tppdm.dprt.o.fidp  >=  0.5 then   
 	   	  var.tppdm.date.o.fidt  =  var.tppdm.date.o.fidt  +  1   
 	   	  endif   
 	  endselect   
 	  if isspace(tpptc255.cstl) or   
 	  not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	   	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	   	  var.tpptc255.pris  =  0.0   
 	   	  var.tpptc255.amos  =  0.0   
 	   	  var.tpptc255.sacu  =  ""   
 	   	  set.mem(var.tpptc255.rtcs,0)   
 	   	  set.mem(var.tpptc255.rtfs,0)   
 	  else   
 	   	  var.tpptc255.pris  =  tpptc255.pris   
 	   	  var.tpptc255.amos  =  tpptc255.amos   
 	   	  var.tpptc255.sacu  =  comp.ccur   
 	   	  var.tpptc255.rtcs(1)  =  1   
 	   	  var.tpptc255.rtcs(2)  =  0   
 	   	  var.tpptc255.rtcs(3)  =  0   
 	   	  var.tpptc255.rtfs(1)  =  1   
 	   	  var.tpptc255.rtfs(2)  =  0   
 	   	  var.tpptc255.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:255
:SCPAC:tp
:SCMOD:ptc
:SFLNO:255
:ICOD:S
:QURY:START
select tpptc255.*  ,   
 	  tpptc050.stlm, tpptc050.stlt   
from 	  tpptc050,   
 	  tpptc255
where 	  tpptc255.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:255
:SCPAC:tp
:SCMOD:ptc
:SFLNO:255
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:265
:SCPAC:tp
:SCMOD:ptc
:SFLNO:265
:ICOD:D
:QURY:START
get.cost.components (bcorig.tppdm,"", tpptc265.ccco, var.o.errmess)   
 	  var.tppdm.date.o.stdt  =  0   
 	  var.tppdm.date.o.fidt  =  0   
 	  var.tppdm.dprt.o.stdp  =  0   
 	  var.tppdm.dprt.o.fidt  =  0   
 	  select  	  tpptc260.*     
 	  from  	  tpptc260   
 	  where  	  tpptc260._index1  =  {:tpptc265.cprj, :tpptc265.cpla, :tpptc265.cact, :tpptc265.sern}   
 	  selectdo   
 	    	  select tppss200.*     
 	    	  from tppss200   
 	    	  where tppss200._index1  =  {:tpptc260.cprj, :tpptc260.cpla, :tpptc260.cact}   
 	    	  selectdo   
 	    	    	  select tppss010.*     
 	    	    	  from tppss010   
 	    	    	  where tppss010._index1  =  {:tpptc260.cprj, :tpptc260.cpla}   
 	    	    	  selectdo   
 	    	    	    	  if tpptc260.rsta  <>  0 or tpptc260.rfin  <>  100 then   
 	    	    	    	    	  if tppss200.capt  =  tppdm.cotp.tasks or tppss200.capt  =  tppdm.cotp.equipment then   
 	    	    	    	    	    	  itppss0032.determine.calendar.level.for.activity (tppss200.cprj, tppss200.cpla, tppss200.cact, tppss200.capt, tppss010.rslv, var.tppss.cltp.l.cltp, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ)   
 	    	    	    	    	  else   
 	    	    	    	    	    	  var.tppss.cltp.l.cltp  =  tppss.cltp.project.cal   
 	    	    	    	    	  endif   
 	    	    	    	  endif   
 	    	    	    	  if tpptc260.rsta  =  0 then   
 	    	    	    	    	  var.tppdm.date.o.stdt  =  tppss200.psdt   
 	    	    	    	    	  var.tppdm.dprt.o.stdp  =  tppss200.psdp   
 	    	    	    	  else   
 	    	    	    	    	  var.tppdm.pltm.l.duration  =  (tpptc260.rsta  /  100.0)  *  tppss200.adur   
 	    	    	    	    	  itppss0030.plan.forward (tppdm.stfi.start,  	  var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ, tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.stdt, var.tppdm.dprt.o.stdp, var.tppdm.s080.l.mess)   
 	    	    	    	  endif   
 	    	    	    	  if tpptc260.rfin  =  100 then   
 	    	    	    	    	  var.tppdm.date.o.fidt  =  tppss200.pfdt   
 	    	    	    	    	  var.tppdm.dprt.o.fidt  =  tppss200.pfdp   
 	    	    	    	  else   
 	    	    	    	    	  var.tppdm.pltm.l.duration  =  (tpptc260.rfin  /  100.0)  *  tppss200.adur   
 	    	    	    	    	  itppss0030.plan.forward (tppdm.stfi.finish, var.tppss.cltp.l.cltp, tppss200.cprj, var.tppdm.ctrg.l.ctrg, var.tcemno.l.emno, var.tppdm.cequ.l.cequ,  	  tppss200.psdt, tppss200.psdp, var.tppdm.pltm.l.duration, var.tppdm.date.o.fidt, var.tppdm.dprt.o.fidt, var.tppdm.s080.l.mess)   
 	    	    	    	  endif   
 	    	    	  endselect   
 	    	  endselect   
 	    	  if var.tppdm.dprt.o.stdp  >=  0.5 then   
 	    	    	  var.tppdm.date.o.stdt  =  var.tppdm.date.o.stdt  +  1   
 	  endif   
 	    	  if var.tppdm.dprt.o.fidt  >=  0.5 then   
 	    	    	  var.tppdm.date.o.fidt  =  var.tppdm.date.o.fidt  +  1   
 	    	  endif   
 	  endselect   
 	  if isspace(tpptc265.cstl) or   
 	   not( tpptc050.stlm  =  tpptc.stlm.techn.budget or   
 	    	  tpptc050.stlt  =  tpptc.stlt.quan.settl ) then   
 	    	  var.tpptc265.pris  =  0.0   
 	    	  var.tpptc265.amos  =  0.0   
 	    	  var.tpptc265.sacu  =  ""   
 	    	  set.mem(var.tpptc265.rtcs,0)   
 	    	  set.mem(var.tpptc265.rtfs,0)   
 	  else   
 	    	  var.tpptc265.pris  =  tpptc265.pris   
 	    	  var.tpptc265.amos  =  tpptc265.amos   
 	    	  var.tpptc265.sacu  =  comp.ccur   
 	    	  var.tpptc265.rtcs(1)  =  1   
 	    	  var.tpptc265.rtcs(2)  =  0   
 	    	  var.tpptc265.rtcs(3)  =  0   
 	    	  var.tpptc265.rtfs(1)  =  1   
 	    	  var.tpptc265.rtfs(2)  =  0   
 	    	  var.tpptc265.rtfs(3)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:265
:SCPAC:tp
:SCMOD:ptc
:SFLNO:265
:ICOD:S
:QURY:START
select  	  tpptc265.*  ,   
 	  tpptc050.stlm, tpptc050.stlt  
from 	  tpptc050,   
 	  tpptc265
where 	  tpptc265.cmbb refers to tpptc050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:265
:SCPAC:tp
:SCMOD:ptc
:SFLNO:265
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:420
:SCPAC:tp
:SCMOD:ptc
:SFLNO:420
:ICOD:D
:QURY:START
var.tpptc420.cprj  =  get.tp.project(tpptc420.cprj)   
 	 get.cost.components(bcorig.tppdm,"",tpptc420.ccco,err.mess)   
 	 get.business.partner(tpptc420.suno,bcstc.orgn.suno,err.mess)   
 	 if isspace(tpptc420.suno) then 	  	  	  	 |# 241263.sn   
 	  	 bcstc008.bpid  =  ""    
 	 else   
 	  	 get.business.partner(tpptc420.suno,bcstc.orgn.suno,err.mess)   
 	 endif 	  	  	  	  	  	  	 |# 241263.en   
 	 if tpptc420.cotp  =  tppdm.cotp.equipment or tpptc420.cotp  =  tppdm.cotp.subcontracting then   
 	  	 var.tpptc420.cequ  =  shiftl$ (tpptc420.item)   
 	  	 var.tpptc420.item (1;47)  =  " "   
 	 else   
 	  	 var.tpptc420.cequ  =  " "   
 	  	 if (read.item (tpptc420.item,tpptc420.cprj,var.mstr.des,2,0,1)  =  tppdm.reft.project) then   
 	  	  	 var.tpptc420.item  =  segment.item.code (tpptc420.item, var.tpptc420.cprj)   
 	  	 else   
 	  	  	 if (read.item (tpptc420.item,tpptc420.cprj,var.mstr.des,2,0,1)  =  tppdm.reft.standard) then   
 	  	  	  	 var.tpptc420.item  =  segment.item.code (tpptc420.item,"")   
 	  	  	 endif   
 	  	 endif   
 	 endif   
 	 var.tpptc420.cono  =  convert.number(bcckon.act.pur.contr, tpptc420.cono)   
 	 if isspace(tpptc420.ccur) then   
 	  	 var.tpptc420.ccur  =  comp.ccur   
 	 else   
 	  	 var.tpptc420.ccur  =  tpptc420.ccur   
 	 endif   
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:420
:SCPAC:tp
:SCMOD:ptc
:SFLNO:420
:ICOD:S
:QURY:START
select tpptc420.*   
from tpptc420
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:420
:SCPAC:tp
:SCMOD:ptc
:SFLNO:420
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:acm
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:D
:QURY:START
|  	  select  	  tiitm001.cpcp, tiitm001.cuni , tiitm001.copr   
 	  select  	  tiitm001.*     
 	  from  	  tiitm001   
 	  where  	  tiitm001.item  =  :tssma121.item   
 	  selectdo   
 	   	  select  	  ticpr010.cref , ticpr010.dsca   
 	   	  from  	  ticpr010   
 	   	  where  	  ticpr010.cpcp  =  :tiitm001.cpcp   
 	   	  selectdo   
 	   	   	  if (tssma121.cjob  =  var.cjob) then   
 	   	   	   	  var.tsacm220.lino  =  var.tsacm220.lino  +  10   
 	   	   	  else   
 	   	   	   	  var.cjob  =  tssma121.cjob   
 	   	   	   	  var.tsacm220.lino  =  10   
 	   	   	  endif   
 	   	   	  fill.quantity()   
 	   	   	  fill.price()   
 	   	   	  fill.price()   
 	   	   	  fill.description()  	   	   	   	  |# 1441025.n   
 	   	   	  dump 1   
 	   	  endselect   
 	  endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:acm
:TFLNO:220
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:S
:QURY:START
select  	  tssma121.*     
from tssma121
order by tssma121.cjob
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:bsc
:TFLNO:100
:SCPAC:ts
:SCMOD:sma
:SFLNO:110
:ICOD:D
:QURY:START
if get.configuration(tssma110.cloc, var.err.mess) then   
 	   	  continue   
 	   	  |   *  Cluster is not generated for the location   
 	  endif   
 	  if not get.business.partner ( tssma110.cuno,bcstc.orgn.cuno, var.err.mess ) then   
 	   	  var.tsbsc100.ofbp  =  bcstc008.bpid   
 	   	  var.tsbsc100.owtp  =  target(tscfg.owtp.external) |# FP10.n   
 	  else   
 	   	  var.tsbsc100.ofbp  =  ""    
 	   	  var.tsbsc100.owtp  =  target(tscfg.owtp.internal) |# FP10.n   
 	  endif   
 	  if get.cross.reference.for.contact.code ( "tssma110", tssma110.cloc, var.err.mess ) then    
 	   	  bcstc005.ccnt  =  empty.string ( 1;9 )   
 	  endif   
 	  if ( len ( shiftl$ ( shiftr$ ( tssma110.cloc )))  >  8 ) then   
 	   	  var.tsbsc100.desc  =  "CONVERSION"  &   tssma110.cloc    
 	  else   
 	   	  if not isspace(tssma110.desc) then  	   	  |# 244887.n   
 	   	   	  var.tsbsc100.desc  =  tssma110.desc   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  else   
 	   	   	  var.tsbsc100.desc  =  tssma110.cloc   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	  endif   
 	  var.tsbsc100.cadr  =  local.get.addresses(0)   
 	  var.tsbsc100.ccor  =  local.get.addresses(1)   
 	  |   *  For field  -  EFTM   
 	  if tssma110.sdat then   
 	   	  var.tsbsc100.eftm  =  utc ( tssma110.sdat,0 )   
 	  else   
 	   	  var.tsbsc100.eftm  =  utc ( 719528,0 )   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:bsc
:TFLNO:100
:SCPAC:ts
:SCMOD:sma
:SFLNO:110
:ICOD:S
:QURY:START
select  	  tssma110.*     
from 	  tssma110
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
get.configuration ( tssma102.cloc, err.mess )   
 	  fill.business.partners()   
 	  fill.tscfg200.owtp()  	   	   	   	   	  |# FP10.n   
 	  if tssma302.cloc  <>  tssma110.cloc then   
 |  	   	  var.tscfg200.ofad  =  local.get.addresses(0)  	  |# 1432972.o   
 |  	   	  var.tscfg200.ladr  =  local.get.addresses(1)  	  |# 1432972.o   
 	   	  var.tscfg200.ofad  =  local.get.addresses(1)  	  |# 1432972.n   
 	   	  var.tscfg200.ladr  =  local.get.addresses(0)  	  |# 1432972.n   
 	  endif   
 	  if is.masterdata.conversion () then   
 	   	  var.str.temp1.cwte  =  empty.string ( 1;16 )   
 	   	  var.tscfg200.srno  =  empty.string(1;9)   
 	   	  var.tscfg200.pono  =  0   
 	   	   	   	   	   	   	   	  |# 1446887.sn   
 	   	  var.tscfg200.ortp  =  99  	  |   *  not applicable   
 	   	   	   	   	   	   	   	  |# 1446887.en   
 	  else   
 	   	  var.str.temp1.cwte  =  tssma102.cgua   
 	   	   	   	   	   	   	   	  |# 1446887.so   
 |  	   	  if not isspace(var.str.temp1.cwte) then  	  |# FP9.sn   
 |  	   	   	  var.tscfg200.sswt  =  tcyesno.yes   
 |  	   	  else   
 |  	   	   	  var.tscfg200.sswt  =  tcyesno.no   
 |  	   	  endif  	   	   	   	   	  |# FP9.en   
 	   	   	   	   	   	   	   	  |# 1446887.eo   
 	   	  var.tscfg200.srno  =  convert.number(bcckon.act.sls,tssma102.orno)   
 	   	  var.tscfg200.pono  =  tssma102.pono   
 	   	  if not isspace(var.tscfg200.srno) then  	   	  |# FP8.sn   
 	   	   	  var.tscfg200.ortp  =  5  	  |   *  sales   
 	   	  else   
 	   	   	  var.tscfg200.ortp  =  99  	  |   *  not applicable   
 	   	  endif  	   	   	   	   	  |# FP8.en   
 	  endif   
 	   	   	   	   	   	   	   	  |# 1446887.sn   
 	  if not isspace(var.str.temp1.cwte) then   
 	   	  var.tscfg200.sswt  =  tcyesno.yes   
 	  else   
 	   	  var.tscfg200.sswt  =  tcyesno.no   
 	  endif   
 	   	   	   	   	   	   	   	  |# 1446887.en   
 	  if dummy.item.has.to.be.used (  	  tssma102.cprj,   
 	   	   	   	   	  tssma102.item ) then   
 	   	  var.bccnv.item.temp1.item  =     
 	   	   	  segment.item.code ( bcsts000.item,empty.string(1;9))   
 	   	  var.str.revi  =  empty.string ( 1;6 )   
 	  else   
 	   	  var.bccnv.item.temp1.item  =     
 	   	   	   	   	   	   	   	  |# Sl200314.so   
 |  	   	   	  segment.item.code ( tssma102.item,tssma102.cprj)   
 	   	   	   	   	   	   	   	  |# SL200314.eo   
 	   	   	   	   	   	   	   	  |# SL200314.sn   
 	   	   	  segment.item.code (  	  tssma102.item,   
 	   	   	   	   	   	  get.project(tssma102.cprj))   
 	   	   	   	   	   	   	   	  |# SL200314.en   
 	   	  var.str.revi  =  tssma102.revi   
 	  endif   
 	  if not ISSPACE ( var.str.temp1.cwte ) then   
 	   	  var.lng.temp.term  =  get.term.ids.for.serialised.item(   
 	   	   	   	   	   	  tssma102.item,   
 	   	   	   	   	   	  tssma102.cins)   
 	  else   
 	   	  var.lng.temp.term  =  0.0   
 	  endif   
 	  fill.status.time()   
 	  dump 1   
 	  if not isspace(var.str.temp1.cwte) then 	  	 |#LN10601.sn   
 	  	 var.tscfg250.cwte  =  var.str.temp1.cwte   
 	  	 var.tscfg250.item  =  var.bccnv.item.temp1.item 	    
 	  	 var.tscfg250.sern  =  tssma102.cins   
 	  	  	    
 	  	 determine.warranty.determined.by()   
 	  	 determine.number.of.periods()   
 	  	 dump 3 	  	 |# tscfg250 	    
 	 endif 	  	  	  	  	  	  	 |#LN10601.en
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:cfg
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:D
:QURY:START
	   	   	   	   	   	   	   	  |# 243873.sn   
 	  if component.item.serial.number.used.as.installation() then   
 	   	  |   *  this will give duplicate serialized items in tscfg200,   
 	   	  |   *  so continue with the next component.   
 	   	  continue   
 	  endif   
 	   	   	   	   	   	   	   	  |# 243873.en   
 	  select tssma104.cins, tssma102.*     
 	  from  	  tssma104, tssma102   
 	  where  	  tssma104.item  =  :tssma105.item   
 	  and  	  tssma104.cser  =  :tssma105.cser   
 	  and  	  tssma104.cins refers to tssma102   
 	  as set with 1 rows   
 	  selectdo   
 	  selectempty   
 	   	  tssma104.cins  =  empty.string ( 1;20 )   
 	   	  tssma102.cloc  =  empty.string ( 1;10 )   
 	   	  var.str.ofbp  =  empty.string ( 1;9 )   
 	   	  var.str.otbp  =  empty.string ( 1;9 )   
 	  endselect   
 	  get.configuration ( tssma102.cloc, err.mess )   
 	  var.str.revi  =  tssma105.revi   
 	  if is.masterdata.conversion () then   
 	   	  var.str.temp2.cwte  =  empty.string ( 1;16 )   
 	   	  var.tscfg200.srno  =  empty.string ( 1;16 )   
 	   	  var.tscfg200.pono  =  0   
 	   	   	   	   	   	   	   	  |# 1446887.sn   
 	   	  var.tscfg200.ortp  =  99  	  |   *  not applicable   
 	   	   	   	   	   	   	   	  |# 1446887.en   
 	  else   
 	   	  var.str.temp2.cwte  =  tssma105.cgua   
 	   	  var.tscfg200.srno  =  convert.number ( bcckon.act.sls,tssma102.orno )   
 	   	  var.tscfg200.pono  =  tssma102.pono   
 	   	  if not isspace(var.tscfg200.srno) then  	   	  |# FP8.sn   
 	   	   	  var.tscfg200.ortp  =  5  	  |   *  sales   
 	   	  else   
 	   	   	  var.tscfg200.ortp  =  99  	  |   *  not applicable   
 	   	  endif  	   	   	   	   	  |# FP8.en   
 	  endif   
 	  if not isspace ( var.str.temp2.cwte ) then   
 	   	  var.lng.temp.term  =  get.term.ids.for.serialised.item (   
 	   	   	   	   	   	   	  tssma105.item,   
 	   	   	   	   	   	   	  tssma105.cser )   
 	   	   	   	   	   	   	   	  |# 1446887.sn   
 	   	  var.tscfg200.sswt  =  tcyesno.yes   
 	  else   
 	   	  var.tscfg200.sswt  =  tcyesno.no   
 	   	   	   	   	   	   	   	  |# 1446887.en   
 	  endif   
 	  if dummy.item.has.to.be.used (  	  "",   
 	   	   	   	   	  tssma105.item ) then   
 	   	  temp.item  =  bcsts000.item   
 	   	  var.str.revi  =  empty.string ( 1;6 )   
 	  else   
 	   	  temp.item  =  tssma105.item   
 	  endif   
 	  var.bccnv.item.temp2.item  =     
 	   	   	  segment.item.code ( temp.item,empty.string ( 1;9 ))   
 	  select tssma110.*     
 	  from tssma110   
 	  where  	  tssma110._index1  =  {:tssma102.cloc}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  fill.business.partners ()   
 	   	  var.tscfg200.ofad  =  local.get.addresses ( 0 )   
 	   	  var.tscfg200.ladr  =  local.get.addresses ( 1 )   
 	  selectempty   
 	   	  var.tscfg200.ofad  =  empty.string ( 1;9 )   
 	  endselect   
 	  if not isspace ( tssma104.cins ) then   
 	   	  if dummy.item.has.to.be.used (  	  tssma102.cprj,   
 	   	   	   	   	   	  tssma102.item ) then   
 	   	   	  var.tscfg200.titm  =  segment.item.code (   
 	   	   	   	  bcsts000.item,empty.string(1;9) )   
 	   	  else   
 |  	   	   	  var.tscfg200.titm  =  segment.item.code (  	  |# 218191.so   
 |  	   	   	   	  tssma102.item,tssma102.cprj )  	   	  |# 218191.eo   
 	   	   	  var.tscfg200.titm  =  segment.item.code (  	  |# 218191.sn   
 	   	   	   	  tssma102.item,   
 	   	   	   	  get.project(tssma102.cprj) )  	   	  |# 218191.en   
 	   	  endif   
 	  else   
 	   	  tssma102.idat  =  0   
 	   	  tssma102.locd  =  empty.string ( 1;30 )   
 	   	  tssma102.suno  =  empty.string ( 1;6 )   
 	   	  var.tscfg200.titm  =  var.bccnv.item.temp2.item   
 	  endif   
 	  fill.status.time ()   
 	  get.tscfg200.optm.for.components()  	   	   	   	  |# FP9.n   
 	  dump 2   
 	  if not isspace(var.str.temp1.cwte) then 	  	 |#LN10601.sn   
 	  	 var.tscfg250.cwte  =  var.str.temp2.cwte   
 	  	 var.tscfg250.item  =  var.bccnv.item.temp2.item 	    
 	  	 var.tscfg250.sern  =  tssma105.cser   
 	  	  	    
 	  	 determine.warranty.determined.by()   
 	  	 determine.number.of.periods()   
 	  	 dump 3 	  	 |# tscfg250 	    
 	 endif 	  	  	  	  	  	  	 |#LN10601.en
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  	  	  	  	  	  	  	 |# 243873.sn   
 	 if shiftl$(strip$(var.str.item))  <>  shiftl$(strip$(var.str.child.item)) or   
 	 shiftl$(strip$(tssma104.cins))  <>  shiftl$(strip$(tssma104.cser)) then   
 	  	  	  	  	  	  	  	 |# 243873.en   
 	  	 var.tscfg210.quan  =  get.quantity() 	  	 |# 1061527.n   
 	  	 dump 1   
 	 endif 	  	  	  	  	  	  	 |# 243873.n
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:ctm
:TFLNO:020
:SCPAC:ts
:SCMOD:sma
:SFLNO:130
:ICOD:D
:QURY:START
if isspace (tssma130.desc) then   
 	    	  var.tsctm020.desc  =  tssma130.cgua   
 	  else   
 	    	  var.tsctm020.desc  =  tssma130.desc   
 	  endif   
 	  term.id  =  get.term.id.for.warranty(tssma130.cgua)   
 	  on case tssma130.ptyp   
 	  case tssma.ptyp.year :   
 	    	  var.tsctm020.peru  =  25   
 	    	  break   
 	  case tssma.ptyp.month :   
 	    	  var.tsctm020.peru  =  15   
 	    	  break   
 	  case tssma.ptyp.week :   
 	    	  var.tsctm020.peru  =  10   
 	    	  break   
 	  endcase   
 	  if (tssma130.gtim  =  0) then   
 	    	  var.tsctm020.peru  =  5   
 	    	  var.lng.nrpe  =  1   
 	  else   
 	    	  var.lng.nrpe  =  tssma130.gtim   
 	  endif   
 	  var.tsctm020.ccur  =  get.home.currency.orig.comp()  	     
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:ctm
:TFLNO:110
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
	  if dummy.item.has.to.be.used(  	  tssma102.cprj,   
 	   	   	   	   	  tssma102.item) then   
 	   	  var.bccnv.item.temp1.item  =     
 	   	  segment.item.code ( bcsts000.item,empty.string ( 1;9 ))   
 	  else   
 	   	  var.bccnv.item.temp1.item  =     
 	   	   	   	   	   	   	   	  |# Sl200314.so   
 |  	   	  segment.item.code ( tssma102.item,tssma102.cprj )   
 	   	   	   	   	   	   	   	  |# Sl200314.eo   
 	   	  segment.item.code ( tssma102.item,  	   	  |# Sl200314.n   
 	   	   	   	  get.project(tssma102.cprj)) |# Sl200314.n   
 	  endif   
 	  fill.dates()   
 	  contract.duration  =  (tssma220.edat  -  (tssma220.sdat  -  1))   
 	  line.duration  	    =  (var.tsctm110.edat  -  (var.tsctm110.sdat  -  1))   
 	  conv.factor  	    =  contract.duration  /  line.duration   
 	  if (tssma220.citp  =  tssma.citp.not) or   
 	  ((tssma220.citp  =  tssma.citp.job) and (tssma102.cpam  =  0.0)) then   
 	   	  var.nsmt  =  1   
 	  else   
 	   	  var.nsmt  =  tssma102.cpam   
 	  endif   
 	  var.gsmt  =  round(var.nsmt  *  conv.factor,4,1)   
 	  var.rsmt  =  var.gsmt   
 	  if var.str.prev.ccon  <>  tssma220.ccon then   
 |  	   	  var.str.ccon  =  convert.10.to.9(tssma220.ccon) |# 1041384.o   
 	   	   	   	   	   	   	   	  |# 1041384.sn   
 	   	  if not get.service.contract(tssma220.ccon, err.mess) then   
 	   	   	  var.str.ccon  =  bcsts007.csco   
 	   	  else   
 	   	   	  var.str.ccon  =  empty.string(1;9)   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 1041384.sn   
 	   	  if tssma220.ctst  =  tssma.ctst.quotation then   
 	   	   	  term.id  =  get.term.id.for.contract.and.quot(   
 	   	   	   	   	   	   	   	  bcsts.appl.quot,   
 	   	   	   	   	   	   	   	  var.str.ccon)   
 	   	  else   
 	   	   	  term.id  =  get.term.id.for.contract.and.quot(   
 	   	   	   	   	   	   	   	  bcsts.appl.cont,   
 	   	   	   	   	   	   	   	  var.str.ccon)   
 	   	  endif   
 	   	  get.status.of.contract(tssma220.ctst, hold.appl)   
 	   	  if hold.appl  =  bcsts.appl.quot then   
 	   	   	  var.tsctm110.csco  =  empty.string ( 1;9 )   
 	   	   	  var.tsctm110.cchn  =  0   
 	   	  else   
 	   	   	  var.tsctm110.csco  =  var.str.ccon   
 	   	   	  var.tsctm110.cchn  =  10   
 	   	  endif   
 	  endif   
 	  if var.str.prev.ccon  =  tssma220.ccon then   
 	   	  var.tsctm110.cfln  =  var.tsctm110.cfln  +  10   
 	  else   
 	   	  var.tsctm110.cfln  =  10   
 	  endif   
 	  dump 1   
 	  var.str.prev.ccon  =  tssma220.ccon
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:ctm
:TFLNO:110
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:S
:QURY:START
select tssma220.*  ,tssma102.*     
from tssma220,tssma102
where tssma102.ccon refers to tssma220 unref skip
order by tssma220.ccon
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:100
:SCPAC:bc
:SCMOD:sts
:SFLNO:002
:ICOD:D
:QURY:START
read.work.center.details(tccom001.cwoc)   
 	  var.wctp  =  get.department.type()   
 	  dump 2   
 	  if sub.work.center()   
 	  and main.work.center.has.to.be.migrated() then   
 	   	  add.main.work.center(tirou001.mnwc)   
 	   	  migrate.the.main.work.center(tirou001.mnwc)   
 	   	  dump 2   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:100
:SCPAC:bc
:SCMOD:sts
:SFLNO:002
:ICOD:S
:QURY:START
select  	  tccom001.cwoc   
from 	  tccom001, bcsts002
where 	  tccom001.emno  =  bcsts002.emno   
 and  	  tccom001.cwoc  <>  ""
group by tccom001.cwoc
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:100
:SCPAC:bc
:SCMOD:sts
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:145
:SCPAC:ts
:SCMOD:sma
:SFLNO:306
:ICOD:D
:QURY:START
Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:145
:SCPAC:ts
:SCMOD:sma
:SFLNO:306
:ICOD:S
:QURY:START
select tssma306.*     
from tssma306
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:145
:SCPAC:ts
:SCMOD:sma
:SFLNO:306
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma102.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma102.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	  if is.item.serialized ( tssma102.item ) then   
 	   	   	  var.lng.seri  =  1   
 	   	   	  var.str.sigr  =  bcsts000.sigr   
 	   	  else   
 	   	   	  var.lng.seri  =  2   
 	   	   	  var.str.sigr  =  empty.string ( 1;6 )   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma102.desc   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:S
:QURY:START
select tssma102.item,  	  tiitm001.seak,tiitm001.cuqs,  	  tiitm001.cups,   
 	  tssma102.desc  	   	   	   	   	   	  |# 244887.n   
from 	  tssma102,tiitm001
where 	  tssma102.item refers to tiitm001 unref skip   
 and  	  tssma102.cprj  =  ""    
 and  	  tiitm001.kitm  <>  tckitm.subcontracting
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:102
:ICOD:X
:QURY:START
select tssma102.item,tssma102.cprj   
 from  	  tssma102   
 where  	  tssma102.cprj  <>  ""    
 and  	  tssma102.item  <>  ""    
 group by tssma102.cprj, tssma102.item   
 selectdo   
 	  select  	  tipcs021.seak,tipcs021.cuni,tipcs021.cprj,   
 	   	  tipcs021.cvat, tcmcs001.tccu   
 	  from  	  tipcs021, tcmcs001   
 	  where  	  tipcs021._index1  =  {:tssma102.cprj,:tssma102.item}   
 	  and  	  tipcs021.cuni refers to tcmcs001   
 	  as set with 1 rows   
 	  selectdo   
 	   	  var.tsmdm200.cprj  =  get.project(tssma102.cprj)  	  |# 218191.n   
 	   	  if tcmcs001.tccu  =  tctccu.piece then   
 	   	   	  |   *  Item is serialized in this case   
 	   	   	  var.lng.seri  =  1   
 	   	   	  var.str.sigr  =  bcsts000.sigr   
 	   	  else   
 	   	   	  var.lng.seri  =  2   
 	   	   	  var.str.sigr  =  empty.string ( 1;6 )   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tipcs021.seak) then   
 	   	   	  var.tsmdm200.sear  =  tipcs021.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma102.item   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 2   
 	   	  var.tsmdm200.cprj  =  empty.string(1;9)  	   	   	  |# 218191.n   
 	  endselect   
 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma104.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma104.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma104.cins   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 4   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:104
:ICOD:S
:QURY:START
select tssma104.*  ,tiitm001.seak,tiitm001.cuqs,tiitm001.cups   
from tssma104,tiitm001
where tssma104.item refers to tiitm001 unref skip   
 and  	  tiitm001.kitm  <>  tckitm.subcontracting   
 and  	  tiitm001.kitm  <>  tckitm.generic
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma105.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma105.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	  if is.item.serialized ( tssma105.item ) then   
 	   	   	  var.lng.seri  =  1   
 	   	   	  var.str.sigr  =  bcsts000.sigr   
 	   	  else   
 	   	   	  var.lng.seri  =  2   
 	   	   	  var.str.sigr  =  empty.string ( 1;3 )   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma105.desc   
 	   	   	  if isspace(var.tsmdm200.sear) then   
 	   	   	   	  var.tsmdm200.sear  =  tssma105.item   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 5   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:S
:QURY:START
select tssma105.*  ,tiitm001.seak,tiitm001.cuqs,tiitm001.cups   
from tssma105,tiitm001
where tssma105.item refers to tiitm001 unref skip   
 and  	  tiitm001.kitm  <>  tckitm.subcontracting   
 and  	  tiitm001.kitm  <>  tckitm.generic
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:105
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:107
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma107.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma107.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma107.item   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 3   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:107
:ICOD:S
:QURY:START
select tssma107.*  ,tiitm001.seak,tiitm001.cuqs,tiitm001.cups   
from tssma107,tiitm001
where tssma107.item refers to tiitm001 unref skip   
 and  	  tiitm001.kitm  <>  tckitm.subcontracting   
 and  	  tiitm001.kitm  <>  tckitm.generic
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:107
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma121.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma121.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma121.cjob   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 6   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:S
:QURY:START
select tssma121.*  ,tiitm001.seak,tiitm001.cuqs,tiitm001.cups   
from tssma121,tiitm001
where tssma121.item refers to tiitm001 unref skip   
 and  	  tiitm001.kitm  <>  tckitm.subcontracting   
 and  	  tiitm001.kitm  <>  tckitm.generic
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:121
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma310.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma310.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma310.item   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 7   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:310
:ICOD:S
:QURY:START
select  	  tssma310.item,tiitm001.seak,  	   	  tiitm001.cuqs,tiitm001.cups,  	   	  tssma310.cprj   
from 	  tssma310,tiitm001
where 	  tssma310.item refers to tiitm001 unref skip   
 and  	  tiitm001.kitm  <>  tckitm.subcontracting   
 and  	  tiitm001.kitm  <>  tckitm.generic
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:D
:QURY:START
if not item.already.dumped(  	  tssma510.item,   
 	   	   	   	   	  empty.string(1;6)) then   
 	   	  item.index  =  item.index  +  1   
 	   	  add.item(tssma510.item,   
 	   	   	  empty.string(1;6),   
 	   	   	  item.index)   
 	   	   	   	   	   	   	   	  |# 244887.sn   
 	   	  if not isspace(tiitm001.seak) then   
 	   	   	  var.tsmdm200.sear  =  tiitm001.seak   
 	   	  else   
 	   	   	  var.tsmdm200.sear  =  tssma510.item   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 244887.en   
 	   	  dump 8   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:S
:QURY:START
select  	  tssma510.item,tiitm001.seak,  	  tiitm001.cuqs,tiitm001.cups,  	  tssma510.cprj   
from 	  tssma510,tiitm001
where 	  tssma510.item refers to tiitm001 unref skip   
 and  	  tiitm001.kitm  <>  tckitm.subcontracting   
 and  	  tiitm001.kitm  <>  tckitm.generic
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:mdm
:TFLNO:200
:SCPAC:ts
:SCMOD:sma
:SFLNO:510
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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(  	   	   	  |# FP6.so   
 |  	   	   	   	  tssma301.cuno,   
 |  	   	   	   	  bcstc.orgn.cuno,   
 |  	   	   	   	  err.mess)  	   	   	  |# FP6.eo   
 	  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 )   
 	  fill.warranty()  	   	   	   	   	   	  |# FP9.n   
 	  dump 1   
 	  dump 2
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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.actual.line()  	   	   	   	   	  |# FP6.n   
 	  fill.cost.type()   
 	  fill.amounts()   
 	  fill.print.on.invoice()   
 	  fill.business.partner()   
 	  if prev.orno  <>  tssma301.orno then   
 	   	  prev.orno  =  tssma301.orno   
 	   	  fill.cluster()   
 	  endif   
 	  fill.countries()   
 	  var.str.emno  =  (tssma301.emno)  ?     
 	   	   	   	  format.emno(tssma301.emno):bcsts000.emno   
 	  if tssma310.scos  >=  tssma.scos.invoiced then   
 	   	  get.tfgld410.podt()   
 	  else   
 	   	  tfgld410.podt  =  0   
 	  endif   
 	  on case var.lng.cotp   
 	  case 5:   
 	   	  fill.quantities()   
 	   	  dump 1   
 	   	  |   *  tssoc220  -  Material   
 	   	  break   
 	  case 10:   
 	   	  dump 2   
 	   	  |   *  tssoc230  -  Labour   
 	   	  break   
 	  default:   
 	   	  fill.travel.spec()   
 	   	   	   	   	   	   	   	  |# 250294.sn   
 	   	  fill.quantities.other.cost.lines()   
 	   	  fill.estimated.cost.price()   
 	   	  if negative.actual.cost.price() then   
 	   	   	  if swapping.signs.allowed() then   
 	   	   	   	  swapp.signs()   
 	   	   	   	  dump 3   
 	   	   	   	  |   *  tssoc240  -  others   
 	   	   	  else   
 	   	   	   	  log.error(sprintf$("Record skipped: service-order %s/%d not "  &     
 	   	   	   	   	  "migrated because cost price is negative ",   
 	   	   	   	   	  tssma310.orno,   
 	   	   	   	   	  tssma310.seqn))   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  else   
 	   	   	   	   	   	   	   	  |# 250294.en   
 	   	   	  dump 3   
 	   	   	  |   *  tssoc240  -  others   
 	   	  endif  	   	   	   	   	   	  |# 250294.n   
 	   	  break   
 	  endcase   
 	  dump 4   
 	  |   *  tssoc400  -  Service order gross margin analysis
:QURY:END
:TEXT:

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

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:spc
:TFLNO:210
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:D
:QURY:START
	  var.counter  =  var.counter  +  1  	   	   	   	  |# FP8.n   
 	     
 	  if not get.configuration(tssma124.cloc, err.mess) then   
 	   	  var.tsspc210.ccfg  =  bcsts005.clst   
 	  else   
 	   	  var.tsspc210.ccfg  =  empty.string(1;8)   
 	  endif   
 	  var.tsspc210.crac  =  tssma124.cjob   
 	  if ( var.tsspc210.ccfg  =  var.str.prev.ccfg and   
 	   	  var.tsspc210.crac  =  var.str.prev.crac ) then   
 	   	  var.tsspc210.aseq  =  var.tsspc210.aseq  +  5   
 	   	  var.tsspc210.lino  =  0   
 	  else   
 	   	  var.tsspc210.aseq  =  5   
 	   	  var.str.prev.crac  =  var.tsspc210.crac   
 	   	  var.str.prev.ccfg  =  var.tsspc210.ccfg   
 	  endif   
 	  fill.tsspc210.aitm.sern(tssma124.cins)  	   	   	   	   	  |# SP5.n   
 	  select tssma121.*  , tiitm001.cpcp,tiitm001.cuni, ticpr010.*     
 	  from tssma121,tiitm001,ticpr010   
 	  where tssma121.item refers to tiitm001 unref clear   
 	  and  	  tiitm001.cpcp refers to ticpr010 unref clear   
 	  and  	  tssma121.cjob  =  :tssma124.cjob   
 	  and  	  ticpr010.cref  =  tccref.material   
 	  order by tssma121.item   
 	  selectdo   
 	   	  var.tsspc210.item  =  segment.item.code ( tssma121.item,   
 |  	   	   	   	   	  var.tsspc210.cprj )  	   	  |# 218191.o   
 	   	   	   	   	  get.project(var.tsspc210.cprj))  	  |# 218191.n   
 	   	  var.tsspc210.lino  =  var.tsspc210.lino  +  10  	     
 	   	  var.tsspc210.qmat  =  tssma121.qana   
 	   	  if ( tssma121.cuni  =  tiitm001.cuni ) then   
 	   	   	  var.tsspc210.qmat  =  tssma121.qana   
 	   	  else   
 	   	   	  var.tsspc210.qmat  =  tssma121.qana  *     
 	   	   	   	  tiitm.dll0003.conv.factor ( "", tiitm001.item,    
 	   	   	   	   	  "", tiitm001.cuni,    
 	   	   	   	   	  tssma121.cuni, true )   
 	   	  endif   
 	   	  dump 1   
 	  endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:spc
:TFLNO:210
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:S
:QURY:START
select  	  tssma124.*     
from 	  tssma124
where 	  tssma124.tadv  <>  tssma.tadv.cancel  	   	
order by tssma124.cloc, tssma124.cjob
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:spc
:TFLNO:212
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:D
:QURY:START
	   var.counter  =  var.counter  +  1   	     	     	     	    |   #  FP8.n   
 	     
 	    |    *  var.tsspc212.sern filled in function fill.tsspc212.aitm.sern   	    |    #  245246.n   
 	   fill.tsspc212.aitm.sern(tssma124.cins)   	     	     	     	    |    #  245246.n   
 	   var.str.ccfg  =  bcsts005.clst   
 	   var.str.crac  =  tssma124.cjob   
 	   if ( var.str.ccfg  =  var.str.prev.ccfg and   
 |    	   var.str.crac  =  var.str.prev.crac ) then   	     	     	     	    |    #  245246.o   
 	   var.str.crac  =  var.str.prev.crac and   	     	     	     	    |    #  245246.n   
 	   var.tsspc212.sern  =  var.str.prev.cins) then   	     	     	    |    #  245246.n   
 	     	   if ( tssma124.seqn  =  var.lng.prev.seqn ) then   
 	     	     	   var.lng.aseq  =  var.lng.prev.aseq   
 	     	     	   var.lng.lino  =  var.lng.lino  +  10   
 	     	   else   
 	     	     	   var.lng.aseq  =  var.lng.aseq  +  5   
 	     	     	   var.lng.lino  =  10   
 	     	   endif   
 	   else   
 	     	   var.str.prev.ccfg  =  var.str.ccfg   
 	     	   var.str.prev.crac  =  var.str.crac   
 	     	   var.str.prev.cins  =  var.tsspc212.sern   	     	     	    |    #  245246.n   
 	     	   var.lng.aseq  =  5   
 	     	   var.lng.lino  =  10   
 	   endif   	     	     
 |    	   fill.tsspc212.aitm.sern(tssma124.cins)   	     	    |    #  SP5.n   	    |    #  245246.o   	     
 	   calculate.price()   
 	   var.lng.prev.aseq  =  var.lng.aseq   
 	   var.lng.prev.seqn  =  tssma124.seqn   
 	   dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:ts
:TCMOD:spc
:TFLNO:212
:SCPAC:ts
:SCMOD:sma
:SFLNO:124
:ICOD:S
:QURY:START
select   	   tssma124.*  , tssma121.*  ,   	     
 	   tiitm001.item, tiitm001.cpcp,tiitm001.dsca,   
 	   tiitm001.ccur, tiitm001.copr,   
 	   ticpr010.*  , bcsts005.clst
from 	   tssma124, tssma121,tiitm001,ticpr010, bcsts005
where 	   tssma121._index1  =  {tssma124.cjob}   
 and   	   tssma124.tadv  <>  tssma.tadv.cancel   
 and   	   tssma124.cloc  =  bcsts005.cloc   
 and   	   tssma121.item refers to tiitm001 unref clear   
 and   	   tiitm001.cpcp refers to ticpr010 unref clear   
 and   	   ticpr010.cref  <>  tccref.material   
 |  order by tssma124.cloc,tssma124.cjob, tssma124.seqn   	     	     	     	    |    #  245246.o
order by tssma124.cloc,tssma124.cins,tssma124.cjob, tssma124.seqn   	     	    |    #  245246.n
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:200
:SCPAC:tt
:SCMOD:aad
:SFLNO:200
:ICOD:D
:QURY:START
	  | only migrate if not allready present on target system   
 	  if not user.present(ttaad200.user) then   
 	   	  dump 1   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:200
:SCPAC:tt
:SCMOD:aad
:SFLNO:200
:ICOD:S
:QURY:START
select ttaad200.*   
from ttaad200
where 	  ttaad200._compnr  =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:200
:SCPAC:tt
:SCMOD:aad
:SFLNO:200
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:201
:SCPAC:tt
:SCMOD:aad
:SFLNO:201
:ICOD:D
:QURY:START
	 | only migrate if not allready present on target system   
 	 if not user.present(ttaad201.user) then   
 	  	 dump 1   
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:201
:SCPAC:tt
:SCMOD:aad
:SFLNO:201
:ICOD:S
:QURY:START
select ttaad201.*   
from ttaad201
where 	 ttaad201._compnr  =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:201
:SCPAC:tt
:SCMOD:aad
:SFLNO:201
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:205
:SCPAC:tt
:SCMOD:aad
:SFLNO:205
:ICOD:D
:QURY:START
	 | only migrate if not allready present on target system   
 	 if not user.present(ttaad205.user) then   
 	  	 dump 1   
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:205
:SCPAC:tt
:SCMOD:aad
:SFLNO:205
:ICOD:S
:QURY:START
select ttaad205.*   
from ttaad205
where ttaad205._compnr  =  0
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:205
:SCPAC:tt
:SCMOD:aad
:SFLNO:205
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:500
:SCPAC:tt
:SCMOD:aad
:SFLNO:500
:ICOD:D
:QURY:START
	 | only migrate if not allready present on target system   
 	 if not job.present(ttaad500.cjob) then   
 	  	 dump 1   
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:500
:SCPAC:tt
:SCMOD:aad
:SFLNO:500
:ICOD:S
:QURY:START
select ttaad500.*   
from ttaad500
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:tt
:TCMOD:aad
:TFLNO:500
:SCPAC:tt
:SCMOD:aad
:SFLNO:500
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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.vpcc  =  10  	  |   *  Fixed Transfer Price  	  |# fp7.n   
 	  var.whinh000.vpad  =  10  	  |   *  Fixed Transfer Price  	  |# fp7.n   
 	  var.whinh000.dirv  =  10  	   	   	   	   	   	  |# fp8.n   
 	  var.whinh000.cssl  =  2  	   	  |   *  No  	   	   	   	  |# fp8.n   
 	  var.whinh000.cswi  =  2  	  |   *  No  	  |# FP10.n   
 	  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:60
:VERS:B4st
:RELE:61
:CUST:f106
: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:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inh
:TFLNO:000
:SCPAC:td
:SCMOD:ilc
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inh
:TFLNO:010
:SCPAC:bc
:SCMOD:swh
:SFLNO:003
:ICOD:D
:QURY:START
	  on case bcswh003.osrc   
 	  case bcosrc.pur:   
 	   	  if not isspace(bcswh003.rcpr) then   
 	   	   	  var.whinh010.ittp  =  1   
 	   	   	  var.whinh010.auol  =  100 |   *  Not Applicable   
 	   	   	  var.whinh010.acol  =  100 |   *  Not Applicable   
 	   	   	  var.whinh010.rcot  =  10 |   *  Not Applicable   
 	   	  else   
 	   	   	  if not isspace(bcswh003.obpr) then   
 	   	   	   	  var.whinh010.ittp  =  2   
 	   	   	   	  var.whinh010.acol  =  20 |   *  Open Line   
 	   	   	   	  var.whinh010.acol  =  80 |   *  Shipment Line   
 	   	   	   	  var.whinh010.rcot  =  2 |   *  Release Outbound Advice   
 	   	   	  endif   
 	   	  endif   
 	   	  break   
 	  case bcosrc.sls:   
 	   	  if not isspace(bcswh003.obpr) then   
 	   	   	  var.whinh010.ittp  =  2   
 	   	   	  var.whinh010.auol  =  20 |   *  Open Line   
 	   	   	  var.whinh010.acol  =  80 |   *  Shipment Line   
 	   	   	  var.whinh010.rcot  =  2 |   *  Release Outbound Advice   
 	   	  else   
 	   	   	  if not isspace(bcswh003.rcpr) then   
 	   	   	   	  var.whinh010.ittp  =  1   
 	   	   	   	  var.whinh010.auol  =  100 |   *  Not Applicable   
 	   	   	   	  var.whinh010.acol  =  100 |   *  Not Applicable   
 	   	   	   	  var.whinh010.rcot  =  10 |   *  Not Applicable   
 	   	   	  endif   
 	   	  endif   
 	   	  break   
 	  case bcosrc.rpl:   
 	   	  if bcswh003.wtrn  =  tcyesno.yes then   
 	   	   	  var.whinh010.ittp  =  5   
 	   	   	  var.whinh010.auol  =  100 |   *  Not Applicable   
 	   	   	  var.whinh010.acol  =  100 |   *  Not Applicable   
 	   	   	  var.whinh010.rcot  =  10 |   *  Not Applicable   
 	   	  else   
 	   	   	  var.whinh010.ittp  =  3   
 	   	   	  var.whinh010.acol  =  20 |   *  Open Line   
 	   	   	  var.whinh010.acol  =  80 |   *  Shipment Line   
 	   	   	  var.whinh010.rcot  =  2 |   *  Release Outbound Advice   
 	   	  endif   
 	   	  break   
 	  endcase   
 	  if isspace(bcswh003.rcpr) then   
 	   	  var.whinh010.rlpr  =  ""    
 	  else   
 	   	  get.procedure(bcswh003.rcpr, err.mess)   
 	   	  var.whinh010.rlpr  =  bcswh002.nprc   
 	  endif   
 	  if isspace(bcswh003.inpr) then   
 	   	  var.whinh010.rapr  =  ""    
 	  else   
 	   	  get.procedure(bcswh003.inpr, err.mess)   
 	   	  var.whinh010.rapr  =  bcswh002.nprc   
 	  endif   
 	  if isspace(bcswh003.obpr) then   
 	   	  var.whinh010.iapr  =  ""    
 	  else   
 	   	  get.procedure(bcswh003.obpr, err.mess)   
 	   	  var.whinh010.iapr  =  bcswh002.nprc   
 	  endif   
 	  if isspace(bcswh003.shpr) then   
 	   	  var.whinh010.ispr  =  ""    
 	  else   
 	   	  get.procedure(bcswh003.shpr, err.mess)   
 	   	  var.whinh010.ispr  =  bcswh002.nprc   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inh
:TFLNO:200
:SCPAC:bc
:SCMOD:swh
:SFLNO:000
:ICOD:D
:QURY:START
	 |  *  workaround to enable Guess function
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inh
:TFLNO:200
:SCPAC:bc
:SCMOD:swh
:SFLNO:000
:ICOD:S
:QURY:START
select bcswh000.sern    
from bcswh000   
 as set with 1 rows
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inh
:TFLNO:200
:SCPAC:bc
:SCMOD:swh
:SFLNO:000
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:td
:SCMOD:inv
:SFLNO:150
:ICOD:D
:QURY:START
	  if not (   
 	    	  tdinv150.koor  =  tckoor.act.sfc or   
 	    	  tdinv150.koor  =  tckoor.act.pur or   
 	    	  tdinv150.koor  =  tckoor.act.sls or   
 	    	  tdinv150.koor  =  tckoor.pcs.wrh or   
 	    	  tdinv150.koor  =  tckoor.sls.quot or   
 	    	  tdinv150.koor  =  tckoor.wrh.order or   
 	    	  tdinv150.koor  =  tckoor.sma.order or   
 	    	  tdinv150.koor  =  tckoor.pss.wrh or   
 	    	  tdinv150.koor  =  tckoor.act.rpl or   
 	    	  tdinv150.koor  =  tckoor.ti.wrh) then   
 	    	  continue   
 	  endif   
 	  if tdinv150.qana  <  0 then   
 	    	  tdinv150.qana  =    -  tdinv150.qana   
 	    	  if tdinv150.kotr  =  tckotr.requirement then   
 	    	    	  tdinv150.kotr  =  tckotr.receipt   
 	    	  else   
 	    	    	  tdinv150.kotr  =  tckotr.requirement   
 	    	  endif   
 	  endif   
 	  var.whinp100.bpid  =  ""    
 	  get.business.partner.due.to.kind.of.order(   
 	    	    	  tdinv150.koor,   
 	    	    	  tdinv150.orno,   
 	    	    	  tdinv150.pono)   
 	  var.whinp100.pono  =  tdinv150.pono  	    	    	   | # 200  -  101937.n   
 	  var.whinp100.prio  =  2147483647  	    	    	    	   | # 246100.n   
 	  var.whinp100.cprj  =  get.ti.project(tdinv150.cprj)  	   | # FP8.sn   
 	  var.whinp100.cact  =  ""    
 	  var.whinp100.cspa  =  ""    
 	  var.whinp100.cstl  =  ""    
 	  var.whinp100.ccco  =  ""   	     	     	     	    | #  FP8.en    
 	  advice  =  false   
 	  on case tdinv150.koor   
 	  case tckoor.act.rpl:   
 	    	  var.whinp100.boml  =  empty()   
 	    	  var.whinp100.ponb  =  tdinv150.ponb   
 |   	    	  select  	  tdrpl100._index1  	    	   | # FP8.o   
 	    	  select tdrpl100._index1,  	    	    	   | # FP8.sn   
 	    	    	  tdrpl100.rprj, tdrpl100.rspa, tdrpl100.ract,   
 	    	    	  tdrpl100.rstl, tdrpl100.rcco,   
 	    	    	  tdrpl100.dprj, tdrpl100.dspa, tdrpl100.dact,   
 	    	    	  tdrpl100.dstl, tdrpl100.dcco  	    	   | # FP8.en   
 	    	  from  	  tdrpl100   
 	    	  where  	  tdrpl100._index1  =  {:tdinv150.orno, :tdinv150.pono}   
 	    	  order by tdrpl100._index1 desc   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  var.whinp100.ponb  =  tdrpl100.srnb   
 	    	    	  if isspace(var.whinp100.cprj) then  	   | # FP8.sn   
 	    	    	    	  if tdinv150.kotr  =  tckotr.requirement then   
 	    	    	    	    	  var.whinp100.cprj  =  get.project(tdrpl100.rprj)   
 	    	    	    	    	  var.whinp100.cspa  =  tdrpl100.rspa   
 	    	    	    	    	  var.whinp100.cact  =  tdrpl100.ract   
 	    	    	    	    	  var.whinp100.cstl  =  tdrpl100.rstl   
 	    	    	    	    	  var.whinp100.ccco  =  determine.cost.components(tdrpl100.rcco)   
 	    	    	    	  else   
 	    	    	    	    	  var.whinp100.cprj  =  get.project(tdrpl100.dprj)   
 	    	    	    	    	  var.whinp100.cspa  =  tdrpl100.dspa   
 	    	    	    	    	  var.whinp100.cact  =  tdrpl100.dact   
 	    	    	    	    	  var.whinp100.cstl  =  tdrpl100.dstl   
 	    	    	    	    	  var.whinp100.ccco  =  determine.cost.components(tdrpl100.dcco)   
 	    	    	    	  endif   
 	    	    	  endif  	    	    	    	    	   | # FP8.en   
 	    	  endselect   
 	    	  break   
 	  case tckoor.wrh.order:   
 	    	  var.whinp100.boml  =  empty()   
 	    	  var.whinp100.ponb  =  1   
 	    	  var.whinp100.pono  =  determine.new.pono(tdinv150.orno) | # 200  -  101937.n   
 	    	  break   
 	  case tckoor.act.pur:   
 	    	  var.whinp100.boml  =  tdinv150.ponb   
 	    	  var.whinp100.ponb  =  0   
 	    	  select  	  tdpur045._index1, tdpur045.date, tcmcs042.coun   
 	    	  from  	  tdpur045, tdpur040, tcmcs042   
 	    	  where  	  tdpur045._index1  =  {:tdinv150.orno, :tdinv150.pono}   
 	    	  and  	  tdpur040.orno  =  tdpur045.orno   
 	    	  and  	  tcmcs042.cotp  =  tdpur040.cotp   
 	    	  order by tdpur045._index1 desc   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  var.whinp100.ponb  =  get.pur.order.line.sequence.number(   
 	    	    	    	    	    	    	  tdpur045.srnb)   
 	    	    	  if tdpur045.date  =  0 and   
 	    	    	  tcmcs042.coun  =  tcyesno.yes then   
 	    	    	    	  advice  =  true   
 	    	    	  endif   
 	    	  endselect   
 	    	  break   
 	  case tckoor.act.sls:   
 	    	  var.whinp100.boml  =  tdinv150.ponb   
 	    	  var.whinp100.ponb  =  0   
 |   	    	  select  	  tdsls045._index1   
 |   	    	  from  	  tdsls045   
 |   	    	  where  	  tdsls045._index1  =  {:tdinv150.orno, :tdinv150.pono}   
 |   	    	  order by tdsls045._index1 desc   
 |   	    	  as set with 1 rows   
 |   	    	  selectdo   
 |   	    	    	  var.whinp100.ponb  =  get.sls.order.line.sequence.number(   
 |   	    	    	    	    	    	    	  tdinv150.orno,   
 |   	    	    	    	    	    	    	  tdinv150.pono,   
 |   	    	    	    	    	    	    	  tdsls045.srnb)   
 |   	    	  endselect   
 	    	  break  	    	    	    	    	    	   | # 800  -  143244.n   
 	    	    	    	    	    	    	    	   | # 200  -  101937.sn   
 	  case tckoor.pcs.wrh:   
 	    	  var.whinp100.boml  =  0   
 	    	  var.whinp100.pono  =  10   
 	    	  var.whinp100.ponb  =  1   
 	    	    	    	    	    	    	    	   | # 200  -  101937.en   
 	    	    	    	    	    	    	    	   | # FP8.sn   
 	    	  select  	  tipcs530.prjt, tipcs530.cspa, tipcs530.cact,   
 	    	    	  tipcs530.cstl, tipcs530.ccco   
 	    	  from  	  tipcs530   
 	    	  where  	  tipcs530.orno  =  :tdinv150.orno   
 	    	  and  	  tipcs530.kood  =  tckood.tp   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  var.whinp100.cprj  =  get.project(tipcs530.prjt)   
 	    	    	  var.whinp100.cspa  =  tipcs530.cspa   
 	    	    	  var.whinp100.cact  =  tipcs530.cact   
 	    	    	  var.whinp100.cstl  =  tipcs530.cstl   
 	    	    	  var.whinp100.ccco  =  determine.cost.components(tipcs530.ccco)   
 	    	  endselect  	    	    	    	    	   | # FP8.en   
 	    	  break   
 	    	    	    	    	    	    	    	   | # 246100.sn   
 	  case tckoor.act.sfc:  	     
 	    	  var.whinp100.boml  =  tdinv150.ponb   
 	    	  var.whinp100.prio  =  999  	     
 	    	  var.whinp100.ponb  =  determine.sequence.for.production(   
 	    	    	    	    	    	    	  tdinv150.orno,   
 	    	    	    	    	    	    	  tdinv150.pono)   
 	    	  break   
 	    	    	    	    	    	    	    	   | # 246100.en   
 	  default:   
 	    	  var.whinp100.boml  =  tdinv150.ponb   
 	    	  var.whinp100.ponb  =  empty()   
 	    	  break   
 	  endcase   
 	    	    	    	    	    	    	    	   | # 200  -  101937.so   
 |   	  if tdinv150.koor  =  tckoor.wrh.order then   
 |   	    	  var.whinp100.pono  =  determine.new.pono(tdinv150.orno)   
 |   	  else   
 |   	    	  var.whinp100.pono  =  tdinv150.pono   
 |   	  endif   
 	    	    	    	    	    	    	    	   | # 200  -  101937.eo   
 	  if advice then   
 	    	  var.whinp100.koor  =  8  	   |   *  purchase order advice   
 	  else   
 	    	  var.whinp100.koor  =  convert.tckoor(tdinv150.koor, tdinv150.orno)   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inp
:TFLNO:100
:SCPAC:ti
:SCMOD:pcs
:SFLNO:500
:ICOD:D
:QURY:START
	  if not (   
 	    	  tipcs500.koor  =  tckoor.act.sfc or   
 	    	  tipcs500.koor  =  tckoor.act.pur or   
 	    	  tipcs500.koor  =  tckoor.act.sls or   
 	    	  tipcs500.koor  =  tckoor.pcs.wrh or   
 	    	  tipcs500.koor  =  tckoor.sls.quot or   
 	    	  tipcs500.koor  =  tckoor.wrh.order or   
 	    	  tipcs500.koor  =  tckoor.sma.order or   
 	    	  tipcs500.koor  =  tckoor.pss.wrh or   
 	    	  tipcs500.koor  =  tckoor.act.rpl or   
 	    	  tipcs500.koor  =  tckoor.ti.wrh) then   
 	    	  continue   
 	  endif   
 	  if tipcs500.qana  <  0 then   
 	    	  tipcs500.qana  =    -  tipcs500.qana   
 	    	  if tipcs500.kotr  =  tckotr.requirement then   
 	    	    	  tipcs500.kotr  =  tckotr.receipt   
 	    	  else   
 	    	    	  tipcs500.kotr  =  tckotr.requirement   
 	    	  endif   
 	  endif   
 	  var.whinp100.cwar  =  tipcs021.cwar  	    	    	    	   | # 1399055.n   
 	  var.whinp100.bpid  =  ""   
 	  get.business.partner.due.to.kind.of.order(   
 	    	    	  tipcs500.koor,   
 	    	    	  tipcs500.orno,   
 	    	    	  tipcs500.pono)   
 	  var.whinp100.ponb  =  tipcs500.sern   
 	  var.whinp100.prio  =  2147483647  	    	    	    	   | # 246100.n   
 	  var.whinp100.cprj  =  get.ti.project(tipcs500.cprj)  	   | # FP8.sn   
 	  var.whinp100.cspa  =  ""   
 	  var.whinp100.cact  =  ""   
 	  var.whinp100.cstl  =  ""   
 	  var.whinp100.ccco  =  ""   	     	     	     	    | #  FP8.en   
 	  advice  =  false   
 	  on case tipcs500.koor   
 	  case tckoor.act.pur:   
 |   	    	  select  	  tdpur045._index1, tdpur045.date, tcmcs042.coun  	   | # 1399055.o   
 	    	  select  	  tdpur045._index1, tdpur045.date,  	   | # 1399055.sn   
 	    	    	    	  tdpur045.cwar, tdpur040.cwar,   
 	    	    	    	  tcmcs042.coun  	    	    	   | # 1399055.en   
 	    	  from  	  tdpur045, tdpur040, tcmcs042   
 	    	  where  	  tdpur045._index1  =  {:tipcs500.orno, :tipcs500.pono}   
 	    	  and  	  tdpur040.orno  =  tdpur045.orno   
 	    	  and  	  tcmcs042.cotp  =  tdpur040.cotp   
 	    	  order by tdpur045._index1 desc   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  var.whinp100.ponb  =  get.pur.order.line.sequence.number(   
 	    	    	    	    	    	    	  tdpur045.srnb)   
 	    	    	  if tdpur045.date  =  0 and   
 	    	    	  tcmcs042.coun  =  tcyesno.yes then   
 	    	    	    	  advice  =  true   
 	    	    	  endif   
 	    	    	  var.whinp100.cwar  =  tdpur.get.warehouse(  	   | # 1399055.sn   
 	    	    	    	    	  tdpur040.cwar,   
 	    	    	    	    	  tdpur045.cwar)  	    	    	   | # 1399055.en   
 	    	  endselect   
 	    	  break   
 	  case tckoor.act.sls:   
 |   	    	  select  	  tdsls045._index1   
 |   	    	  from  	  tdsls045   
 |   	    	  where  	  tdsls045._index1  =  {:tipcs500.orno, :tipcs500.pono}   
 |   	    	  order by tdsls045._index1 desc   
 |   	    	  as set with 1 rows   
 |   	    	  selectdo   
 |   	    	    	  var.whinp100.ponb  =  get.sls.order.line.sequence.number(   
 |   	    	    	    	    	    	    	  tipcs500.orno,   
 |   	    	    	    	    	    	    	  tipcs500.pono,   
 |   	    	    	    	    	    	    	  tdsls045.srnb)   
 |   	    	  endselect   
 	    	  select  	  tdsls041.cwar  	    	   | # 1399055.sn   
 	    	  from  	  tdsls041   
 	    	  where  	  tdsls041._index1  =  {:tipcs500.orno, :tipcs500.pono}   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  var.whinp100.cwar  =  tdsls041.cwar   
 	    	  endselect  	    	    	    	    	    	   | # 1399055.en   
 	    	  break   
 	    	    	    	    	    	    	    	    	   | # 200  -  101937.sn   
 	  case tckoor.pcs.wrh:   
 	    	  tipcs500.pono  =  10   
 	    	  var.whinp100.ponb  =  1   
 	    	    	    	    	    	    	    	   | # FP8.sn   
 	    	  select tipcs530.prjt, tipcs530.cspa, tipcs530.cact,   
 	    	    	  tipcs530.cstl, tipcs530.ccco,   
 	    	    	  tipcs530.kood, tipcs530.cwar, tipcs530.swar,  	   | # 1399055.n   
 	    	    	  tipcs530.wart  	    	    	    	   | # 1399055.n   
 	    	  from  	  tipcs530   
 	    	  where  	  tipcs530.orno  =  :tipcs500.orno   
 |   	    	  and  	  tipcs530.kood  =  tckood.tp  	   | # 1399055.o   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  on case tipcs530.kood  	    	    	    	   | # 1399055.sn   
 	    	    	  case tckood.wp:   
 	    	    	    	  if tipcs500.kotr  =  tckotr.requirement then   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.swar   
 	    	    	    	  else   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.cwar   
 	    	    	    	  endif   
 	    	    	    	  break   
 	    	    	  case tckood.pw:   
 	    	    	    	  if tipcs500.kotr  =  tckotr.requirement then   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.cwar   
 	    	    	    	  else   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.swar   
 	    	    	    	  endif   
 	    	    	    	  break   
 	    	    	  case tckood.pp:   
 	    	    	    	  if tipcs500.kotr  =  tckotr.requirement then   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.cwar   
 	    	    	    	  else   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.wart   
 	    	    	    	  endif   
 	    	    	    	  break   
 	    	    	  case tckood.tp:   
 	    	    	    	  if tipcs500.kotr  =  tckotr.requirement then   
 	    	    	    	    	  var.whinp100.cwar  =  tipcs530.cwar   
 	    	    	    	  endif  	    	    	    	    	   | # 1399055.en   
 	    	    	    	  var.whinp100.cprj  =  get.project(tipcs530.prjt)   
 	    	    	    	  var.whinp100.cspa  =  tipcs530.cspa   
 	    	    	    	  var.whinp100.cact  =  tipcs530.cact   
 	    	    	    	  var.whinp100.cstl  =  tipcs530.cstl   
 	    	    	    	  var.whinp100.ccco  =  determine.cost.components(tipcs530.ccco)   
 	    	    	    	  break  	    	    	    	    	   | # 1399055.sn   
 	    	    	  endcase  	    	    	    	    	    	   | # 1399055.en   
 	    	  endselect  	    	    	    	    	   | # FP8.en   
 	    	  break   
 	    	    	    	    	    	    	    	    	   | # 200  -  101937.en   
 	    	    	    	    	    	    	    	    	   | # 246100.sn   
 	  case tckoor.act.sfc:   
 	    	  var.whinp100.ponb  =  determine.sequence.for.production(   
 	    	    	    	    	    	    	  tipcs500.orno,   
 	    	    	    	    	    	    	  tipcs500.pono)   
 	    	  var.whinp100.prio  =  999  	    	    	    	   | # 246100.n   
 	    	  if tipcs500.kotr  =  tckotr.requirement then  	   | # 1399055.sn   
 	    	    	  select  	  ticst001.cwar   
 	    	    	  from  	  ticst001   
 	    	    	  where  	  ticst001._index1  =  {:tipcs500.orno, :tipcs500.pono}   
 	    	    	  as set with 1 rows   
 	    	    	  selectdo   
 	    	    	    	  var.whinp100.cwar  =  ticst001.cwar   
 	    	    	  endselect   
 	    	  else   
 	    	    	  select  	  tisfc001.cwar   
 	    	    	  from  	  tisfc001   
 	    	    	  where  	  tisfc001._index1  =  {:tipcs500.orno}   
 	    	    	  as set with 1 rows   
 	    	    	  selectdo   
 	    	    	    	  var.whinp100.cwar  =  tisfc001.cwar   
 	    	    	  endselect   
 	    	  endif  	    	    	    	    	    	   | # 1399055.en   
 	    	  break   
 	    	    	    	    	    	    	    	    	   | # 246100.en   
 	  case tckoor.act.rpl:  	    	    	    	    	   | # FP8.sn   
 |   	    	  if isspace(var.whinp100.cprj) then  	    	    	   | # 1399055.o   
 	    	  select  	  tdrpl100._index1,   
 	    	    	    	  tdrpl100.rprj, tdrpl100.rspa, tdrpl100.ract,   
 	    	    	    	  tdrpl100.rstl, tdrpl100.rcco,   
 	    	    	    	  tdrpl100.dprj, tdrpl100.dspa, tdrpl100.dact,   
 	    	    	    	  tdrpl100.dstl, tdrpl100.dcco,   
 	    	    	    	  tdrpl100.rwar, tdrpl100.dwar  	    	   | # 1399055.n   
 	    	  from  	  tdrpl100   
 	    	  where  	  tdrpl100._index1  =  {:tipcs500.orno, :tipcs500.pono}   
 	    	  order by tdrpl100._index1 desc   
 	    	  as set with 1 rows   
 	    	  selectdo   
 	    	    	  if tipcs500.kotr  =  tckotr.requirement then   
 	    	    	    	  if isspace(var.whinp100.cprj) then  	   | # 1399055.n   
 	    	    	    	    	  var.whinp100.cprj  =  get.project(tdrpl100.rprj)   
 	    	    	    	    	  var.whinp100.cspa  =  tdrpl100.rspa   
 	    	    	    	    	  var.whinp100.cact  =  tdrpl100.ract   
 	    	    	    	    	  var.whinp100.cstl  =  tdrpl100.rstl   
 	    	    	    	    	  var.whinp100.ccco  =  determine.cost.components(tdrpl100.rcco)   
 	    	    	    	  endif  	    	    	    	    	   | # 1399055.n   
 	    	    	    	  var.whinp100.cwar  =  tdrpl100.rwar  	   | # 1399055.n   
 	    	    	  else   
 	    	    	    	  if isspace(var.whinp100.cprj) then  	   | # 1399055.n   
 	    	    	    	    	  var.whinp100.cprj  =  get.project(tdrpl100.dprj)   
 	    	    	    	    	  var.whinp100.cspa  =  tdrpl100.dspa   
 	    	    	    	    	  var.whinp100.cact  =  tdrpl100.dact   
 	    	    	    	    	  var.whinp100.cstl  =  tdrpl100.dstl   
 	    	    	    	    	  var.whinp100.ccco  =  determine.cost.components(tdrpl100.dcco)   
 	    	    	    	  endif  	    	    	    	    	   | # 1399055.n   
 	    	    	    	  var.whinp100.cwar  =  tdrpl100.dwar  	   | # 1399055.n   
 	    	    	  endif   
 	    	  endselect   
 |   	    	  endif  	    	    	    	    	    	   | # 1399055.o   
 	    	  break  	    	    	    	    	    	   | # FP8.en   
 	  endcase   
 	  if advice then   
 	    	  var.whinp100.koor  =  8  	   |   *  purchase order advice   
 	  else   
 	    	  var.whinp100.koor  =  convert.tckoor(tipcs500.koor, tipcs500.orno)   
 	  endif   
 	  dump 2
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inr
:TFLNO:000
:SCPAC:td
:SCMOD:inv
:SFLNO:000
:ICOD:D
:QURY:START
	 select tcmcs096.koda   
 	 from 	 tcmcs096   
 	 where tcmcs096._index1  =  {"INV", 1}   
 	 selectdo   
 	  	 |var.whinr000.ladt  =  utc(lval(tcmcs096.koda),0)   
 	  	 var.tcmcs096.koda  =  fill.mc.field.string(tcmcs096.koda,1)   
 	  	 var.whinr000.ladt  =  utc(lval(var.tcmcs096.koda),0)   
 	 selectempty   
 	  	 var.whinr000.ladt  =  utc(0, 0)   
 	 endselect   
 	 var.whinr000.indt  =  utc(0,0)   
 	 var.whinr000.dsca  =  form.text$("bcstc00035") 	 |  *  Actual Set   
 	 Dump 1   
 	 var.whinr000.indt  =  utc(date.num(), time.num())   
 	 var.whinr000.dsca  =  form.text$("bcstc00036") 	 |  *  Converted from BaanIVc4   
 	 Dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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   
 	  hold.tdinv700.sern  =  tdinv700.sern   
 	  var.whinr110.trdt  =  utc(tdinv700.trdt, 0)   
 	  if check1.trdt  <>  tdinv700.trdt then   
 	   	  check1.trdt  =  tdinv700.trdt   
 	   	  var.whinr110.seqn  =  1   
 	  else   
 	   	  var.whinr110.seqn  =  var.whinr110.seqn  +  1   
 	  endif   
 	     
 	  if hold.item  <>  tdinv700.item or   
 	  hold.cwar  <>  tdinv700.cwar then   
 	   	  var.whinr110.seqn  =  1   
 	   	  var.whinr110.qhnd  =  0.0   
 	   	  if hold.negative  >  0 then   
 	   	   	  var.whwmd255.coqu  =  hold.negative   
 	   	   	  dump 13 |# whwmd255   
 	   	   	  hold.negative  =  0.0   
 	   	  endif   
 	   	  if tdinv700.item  <>  hold.item then   
 	   	   	  select tiitm001.stva, tiitm001.ltcp,   
 	   	   	  	 tiitm001.kltc 	  	  	  |#2043803.n   
 	   	   	  from  	  tiitm001   
 	   	   	  where  	  tiitm001._index1  =  {:tdinv700.item}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  endif   
 	   	  if tiitm001.stva  =  tcstva.stnd.copr then   
 	   	   	  var.whinr110.valm  =  1 |*  ftp   
 	   	  else   
 	   	   	  if lot.controlled.item("", tdinv700.item) then   
 	   	   	   	  var.whinr110.valm  =  5  	  |*  lot   
 	   	   	   	  determine.lot.inventory.onhand(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  tdinv700.cwar,   
 	   	   	   	   	   	   	  nr.lots,   
 	   	   	   	   	   	   	  arr.lots)   
 	   	   	  else   
 	   	   	   	  var.whinr110.valm  =  6  	  |*  serial   
 	   	   	   	  determine.lot.inventory.onhand(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  tdinv700.cwar,   
 	   	   	   	   	   	   	  nr.lots,   
 	   	   	   	   	   	   	  arr.lots)   
 	   	   	  endif   
 	   	  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  =  1   
 	   	  dummy.receipt.qty  =  0.0   
 	   	  dummy.array.nr  =  0   
 	   	  receipt.counter  =  0   
 	   	  g.ret  =  set.mem(arr.whina112.trdt, "")    
 	   	  g.ret  =  set.mem(arr.whina112.seqn, 0)   
 	   	  g.ret  =  set.mem(arr.whina112.qskt, 0.0)   
 	   	  select tdinv700._index1,   
 	   	   	  tdinv700.quan:curr.quan,   
 	   	   	  tdinv700.koor:curr.koor,   
 	   	   	  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   
 	   	   	  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   
 	   	   	  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 and   
 	   	   	  curr.koor  <>  tckoor.act.sls and curr.koor  <>  tckoor.sma.order) or   
 	   	   	  (curr.kost  =  tckost.stc.transfer and curr.quan  <  0 and   
 	   	   	  (curr.koor  =  tckoor.act.sls or curr.koor  =  tckoor.sma.order)) then   
 	   	   	   	  to.be.received  =  to.be.received  +  abs(curr.quan)   
 	   	   	   	  i  =  i  +  1   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  array.len  =  array.len  +  200   
 	   	   	   	   	  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, 0)   
 	   	   	   	  arr.whina112.seqn(i)  =  check.seqn   
 	   	   	   	  arr.whina112.qskt(i)  =  abs(curr.quan)   
 	   	   	  else   
 	   	   	   	  issued  =  issued  +  abs(curr.quan)   
 	   	   	  endif   
 	   	  selecteos   
 	   	   	  onhand.inventory  =  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  =  1   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  array.len  =  array.len  +  200   
 	   	   	   	   	  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(date.to.num(1980,1,1), 0)   
 	   	   	   	  arr.whina112.seqn(i)  =  1   
 	   	   	   	  arr.whina112.qskt(i)  =  dummy.receipt.qty   
 	   	   	   	  dummy.array.nr  =  i   
 	   	   	   	  create.tdinv700.correction.record()   
 	   	   	  else   
 	   	   	   	  i  =  2   
 	   	   	  endif   
 	   	  endselect   
 	   	  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  =  " "   
 	  var.whinr110.shpo  =  0   
 	  var.whinr110.rcno  =  " "   
 	  var.whinr110.rcln  =  0   
 	  on case tdinv700.koor   
 	  case tckoor.act.pur:   
 	   	  if not get.business.partner(tdinv700.rlcd, bcstc.orgn.suno, o.mess) then   
 	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	  endif   
 	   	  get.purchase.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.rcno,   
 	   	   	   	  var.whinr110.rcln,   
 	   	   	   	  var.whinr110.srnb,   
 	   	   	   	  bom.line)   
 	   	   	   	   	     
 	   	  if tdinv700.quan  <  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	  break   
 	  case tckoor.act.sls:   
 	   	  if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	  endif   
 	   	  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)   
 	   	  |*  shipment  /  line number are needed for COGS determination   
 	   	  |*  filling is conform include ibcswh0007   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  else   
 	   	   	   	  |*  When there is nothing found for the   
 	   	   	   	  |*  order sequence, then search for sequence 0   
 	   	   	   	  |*  This is needed because ILC records are also   
 	   	   	   	  |*  added to bcswh008. When there is found a   
 	   	   	   	  |*  record, the shipment line number will be   
 	   	   	   	  |*  made 0.   
 	   	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  0,  	  |*  Sequence   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  0   
 	   	   	   	  else   
 	   	   	   	   	  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   
 	   	   	  endif   
 	   	  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   
 	   	   	   	   	   	   	   	     
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  0,  	   	  |*  sequence   
 	   	   	   	   	  0,  	   	  |*  Outbound Sequence   
 	   	   	   	   	  0,  	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	  break   
 	  case tckoor.act.sfc:   
 	   	  if tdinv700.kost  =  tckost.stc.transfer then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  endif   
 	   	  break   
 	  case tckoor.wrh.order :   
 	   	  if tdinv700.kost  <>  tckost.stc.correction then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  else   
 	   	   	  var.whinr110.pono  =  determine.new.pono(tdinv700.orno)   
 	   	  endif   
 	   	  if tdinv700.kost  <>  tckost.stc.correction and   
 	   	  tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  1,  	   	  |*  sequence   
 	   	   	   	   	  0,  	   	  |*  Outbound Sequence   
 	   	   	   	   	  0,  	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	  break   
 	  case tckoor.act.rpl :   
 	   	  if tdinv700.kost  =  tckost.stc.transfer then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  endif   
 	   	  var.whinr110.srnb  =  determine.rpl.order.sequence(  	  tdinv700.orno,   
 	   	   	   	   	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	   	   	   	   	  tdinv700.kost,   
 	   	   	   	   	   	   	   	   	  tdinv700.cwar,   
 	   	   	   	   	   	   	   	   	  hold.tdinv700.trdt)   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  1,  	   	  |*  sequence   
 	   	   	   	   	  0,  	   	  |*  Outbound Sequence   
 	   	   	   	   	  0,  	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	  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   
 	   	  var.whinr110.pono  =  10   
 	   	  var.whinr110.srnb  =  1   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  0,  	   	  |*  sequence   
 	   	   	   	   	  0,  	   	  |*  Outbound Sequence   
 	   	   	   	   	  0,  	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	  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   
 	  tdinv700.kost  =  tckost.stc.transfer and tdinv700.quan  >  0 then  	   	     
 	   	  var.whinr110.kost  =  5  	   	   	  | tckost.issue  	   	   	     
 	  else   
 	   	  if tdinv700.koor  =  tckoor.act.sfc and   
 	   	  tdinv700.kost  =  tckost.stc.transfer and   
 	   	  tdinv700.pono  <>  0 then  	   	   	  | material   
 	   	   	  var.whinr110.kost  =  5  	   	  | issue   
 	   	   	  if tdinv700.quan  >  0 then   
 	   	   	   	  var.whinr110.qstk  =    -  tdinv700.quan  	  | negative issue   
 	   	   	  else   
 	   	   	   	  var.whinr110.qstk  =  abs(tdinv700.quan)   
 	   	   	  endif   
 	   	  else  	   	   	   	   	   	   	   	   	     
 	   	   	  var.whinr110.kost  =  convert.tckost(tdinv700.kost, tdinv700.quan)   
 	  	  	  	  	  	  	  	  	  	 |#1992163.sn   
 	  	  	  |*  In case of tdinv700.koor  =  tckoor.wrh.order the   
 	  	  	  |*  whinhr110.qstk is made positive (abs(tdinv700.quan)).   
 	  	  	  |*  An exception is made for the adjustments.   
 	  	  	  |*  tdinv700.kost  =  1 (Adjustment)   
 	  	  	  |*   	  	  	   	  	  	  	  	    
 	  	  	  |*  in the below cases the negative tdinv700.quan must be taken.   
 	  	  	  |*  case var.whinr110.kost is Receipt (3):   
 	  	  	  |*   tdinv700.kost  =  4 (Purchase manual)   
 	  	  	  |*   tdinv700.kost  =  8 (Production manual receipt)   
 	  	  	  |*  case var.whinr110.kost is Issue (5):   
 	  	  	  |*   tdinv700.kost  =  6 (Sales manual)   
 	  	  	  |*   tdinv700.kost  =  7 (Production manual issue)   
 	  	  	  |*     
 	  	  	  |*  For transfers the absolute quantitiy of tdinv700.quan must be taken.   
 	  	  	  |*  Because for transfer the var.whinr110.kost is changed to an issue when   
 	  	  	  |*  the quantity is negative. This is correct and must be excluded   
 	  	  	  |*  from the correction below.   
 	  	  	    
 	  	  	  |*  Correct Receipts: Keep negative tdinv700.quan   
 	  	  	  	  	  	  	  	  	  	 |#1992163.en   
 	   	   	  if var.whinr110.kost  =  3 and  	   	   	 |*  receipt   
 	   	   	  tdinv700.kost  <>  tckost.stc.transfer and 	  	 |#1992163.n 	   	   	     
 	   	   	  tdinv700.koor  =  tckoor.wrh.order and   
 	   	   	  var.whinr110.qstk  >  0 and   
 	   	   	  tdinv700.quan  <  0 then   
 	   	   	   	  var.whinr110.qstk  =  tdinv700.quan   
 	   	   	  endif  	   	   	   	   	   	   	     
 	   	   	  	  	  	  	  	  	  	 |#1992163.sn   
 	  	  	  |*  Correct Issues: Keep negative tdinv700.quan   
 	   	   	  if var.whinr110.kost  =  5 and  	   	   	 |*  Issue   
 	   	   	  tdinv700.kost  <>  tckost.stc.transfer and   
 	   	   	  tdinv700.koor  =  tckoor.wrh.order and   
 	   	   	  var.whinr110.qstk  >  0 and   
 	   	   	  tdinv700.quan  <  0 then   
 	   	   	   	  var.whinr110.qstk  =  tdinv700.quan   
 	   	   	  endif  	   	   	   	   	   	   	     
 	   	   	  	  	  	  	  	  	  	 |#1992163.en   
 	   	  endif   
 	  endif   
 	  itid  =  itid  +  1   
 	  var.whinr110.itid  =  edit$(itid,"999999999")   
 	  var.whinr110.itse  =  1   
 	  |*  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   
 | 	  if var.whinr110.valm  =  5 then  	  	  	 |#2043803.so   
 | 	   	  var.whinr110.clot  =  determine.lot(hold.tdinv700.trdt)   
 	  	  	  	  	  	  	  	 |#2043803.eo   
 	 var.whina112.clot  =  "" 	  	  	  	  |#2043803_2.n   
 	  if tiitm001.kltc  =  tckltc.batch then 	  	 |#2043803.sn   
 	  	 determine.transaction.type.and.quantity(   
 	  	  	  	  	 tdinv700.koor,   
 	  	  	  	  	 tdinv700.cprj,   
 	  	  	  	  	 tdinv700.quan,   
 	  	  	  	  	 tdinv700.kost,   
 	  	  	  	  	 ilc.quantity, 	  	 |*  ref   
 	  	  	  	  	 ilc.transaction.type) 	 |*  ref   
 	   	  var.whinr110.clot  =  determine.lot(   
 	  	  	  	  	  	 ilc.quantity,   
 	   	  	  	  	  	 ilc.transaction.type,   
 	   	  	  	  	  	 hold.tdinv700.trdt)   
 	   	  	  	  	  	  	  	 |#2043803.en   
 	  	 if var.whinr110.valm  =  5 then  	  	 |#2043803_2.sn   
 	  	  	 var.whina112.clot  =  var.whinr110.clot   
 	  	 endif  	  	  	  	  	 |#2043803_2.en   
 	  else   
 	   	  var.whinr110.clot  =  empty()   
 	  endif   
 | 	  if var.whinr110.valm  =  6 then  	  	  	 |#2043803.so   
 | 	   	  var.whinr110.serl  =  determine.lot(hold.tdinv700.trdt)   
 	  	  	  	  	  	  	  	 |#2043803.eo   
 	 var.whina112.serl  =  "" 	  	  	  	 |#2043803_2.n   
 	  if tiitm001.kltc  =  tckltc.unit then 	  	 |#2043803.sn   
 	  	 determine.transaction.type.and.quantity(   
 	  	  	  	  	 tdinv700.koor,   
 	  	  	  	  	 tdinv700.cprj,   
 	  	  	  	  	 tdinv700.quan,   
 	  	  	  	  	 tdinv700.kost,   
 	  	  	  	  	 ilc.quantity, 	  	 |*  ref   
 	  	  	  	  	 ilc.transaction.type) 	 |*  ref   
 	   	  var.whinr110.serl  =  determine.lot(   
 	  	  	  	  	  	 ilc.quantity,   
 	   	  	  	  	  	 ilc.transaction.type,   
 	   	  	  	  	  	 hold.tdinv700.trdt)   
 	   	  	  	  	  	  	  	 |#2043803.en   
 	  	 if var.whinr110.valm  =  6 then  	  	 |#2043803_2.sn   
 	  	  	 var.whina112.serl  =  var.whinr110.serl   
 	  	 endif  	  	  	  	  	 |#2043803_2.en   
 	  else   
 	   	  var.whinr110.serl  =  empty()   
 	  endif  	     
 	  if (tdinv700.kost  =  tckost.stc.correction and tdinv700.quan  >  0) or   
 	  ((tdinv700.kost  =  tckost.pur.receipt or   
 	  tdinv700.kost  =  tckost.prd.receipt or   
 	  tdinv700.kost  =  tckost.rpl.receipt) and tdinv700.quan  >  0) or   
 	  ((tdinv700.kost  =  tckost.sls.delivery or   
 	  tdinv700.kost  =  tckost.prd.mat.issue or   
 	  tdinv700.kost  =  tckost.rpl.delivery) and tdinv700.quan  <  0) or   
 	  (tdinv700.kost  =  tckost.stc.transfer and tdinv700.quan  >  0 and   
 	  tdinv700.koor  <>  tckoor.act.sls and tdinv700.koor  <>  tckoor.sma.order) or   
 	  (tdinv700.kost  =  tckost.stc.transfer and tdinv700.quan  <  0 and   
 	  (tdinv700.koor  =  tckoor.act.sls or tdinv700.koor  =  tckoor.sma.order)) then   
 	   	  if var.whinr110.valm  =  5 or var.whinr110.valm  =  6 then   
 	   	   	  var.whina112.qstk  =  abs(tdinv700.quan)   
 	   	   	  receipt.counter  =  receipt.counter  +  1   
 	   	   	  to.be.received  =  to.be.received  -  abs(tdinv700.quan)   
 	   	   	  if to.be.received  >=  onhand.inventory then   
 	   	   	   	  |*  totally consumed   
 	   	   	   	  dump 1  	   	  |# whinr110   
 	   	   	   	  var.whina112.qskt  =  0.0   
 	   	   	   	  dump 3  	   	  |# whina112   
 	   	   	   	  if isspace(var.whinr110.clot) and   
 	   	   	   	  isspace(var.whinr110.serl) then   
 	  	  	  	  	 |*  Exception for lot or serial priced item |#2043803_2.n   
 	   	   	   	   	  get.standard.cost.price(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  var.whina112.qstk,   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  true,   
 	   	   	   	   	   	   	  false)   
 	   	   	   	  else   
 	   	   	   	   	  if not isspace(var.whinr110.serl) then   
 	   	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 	   	   	   	   	  else   
 	   	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 	   	   	   	   	  endif   
 	   	   	   	   	  get.lot.price(  	  tdinv700.item,   
 	   	   	   	   	   	   	  lot.serial,   
 	   	   	   	   	   	   	  var.whina112.qstk,   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  false,  	     
 	   	   	   	   	   	   	  true,   
 	   	   	   	   	   	   	  false)   
 	   	   	   	  endif   
 	   	   	  else   
 	   	   	   	  split.up.lots.inventory()   
 	   	   	  endif   
 	   	  else   
 	  	  	 |*  var.whinr110.valm  =  1 	  	  	 |# 2043803_2.n   
 	   	   	  dump 1  	   	  |# whinr110   
 	   	   	  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  	   	  |# whina112   
 | 	   	   	  if isspace(var.whinr110.clot) and 	 |#2043803_2.o   
 | 	   	   	  isspace(var.whinr110.serl) then  	 |#2043803_2.o   
 	   	   	   	  get.standard.cost.price(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  abs(tdinv700.quan),   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  true,   
 	   	   	   	   	   	   	  false)   
 | 	   	   	  else  	  	  	  	 |#2043803_2.so   
 | 	   	   	   	  if not isspace(var.whinr110.serl) then   
 | 	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 | 	   	   	   	  else   
 | 	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 | 	   	   	   	  endif   
 | 	   	   	   	  get.lot.price(  	  tdinv700.item,   
 | 	   	   	   	   	   	  lot.serial,   
 | 	   	   	   	   	   	  abs(tdinv700.quan),   
 | 	   	   	   	   	   	  hold.tdinv700.trdt,   
 | 	   	   	   	   	   	  false,   
 | 	   	   	   	   	   	  true,   
 | 	   	   	   	   	   	  false)   
 | 	   	   	  endif  	  	  	  	 |#2043803_2.eo   
 	   	  endif   
 	  else   
 	   	  dump 1  	   	   	  |# whinr110   
 	   	  remain.quan  =  abs(tdinv700.quan)   
 	   	  if arr.whina112.qskt(i)  =  0 then   
 	   	   	  if tdinv000.nega  =  tcyesno.yes then   
 	   	   	   	  dump 11  	  |# whina120   
 	   	   	   	  hold.negative  =  hold.negative  +  abs(tdinv700.quan)   
 | 	   	   	   	  if isspace(var.whinr110.clot) and |#2043803_2.o   
 | 	   	   	   	  isspace(var.whinr110.serl) then |#2043803_2.o   
 	   	   	   	  if isspace(var.whina112.clot) and |#2043803_2.n   
 	   	   	   	  isspace(var.whina112.serl) then |#2043803_2.n   
 	   	   	   	   	  get.standard.cost.price(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  abs(tdinv700.quan),   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	  true)   
 	   	   	   	  else   
 	   	   	   	   	  	  	  	 |#2043803_2.so   
 | 	   	   	   	   	  if not isspace(var.whinr110.serl) then   
 | 	   	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 | 	   	   	   	   	  else   
 | 	   	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 | 	   	   	   	   	  endif  	  	 |#2043803_2.eo   
 	   	   	   	   	  	  	  	 |#2043803_2.sn   
 	   	   	   	   	  if not isspace(var.whina112.serl) then   
 	   	   	   	   	   	  lot.serial  =  var.whina112.serl   
 	   	   	   	   	  else   
 	   	   	   	   	   	  lot.serial  =  var.whina112.clot   
 	   	   	   	   	  endif  	  	 |#2043803_2.en   
 	   	   	   	   	  get.lot.price(  	  tdinv700.item,   
 	   	   	   	   	   	   	  lot.serial,   
 	   	   	   	   	   	   	  abs(tdinv700.quan),   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	  true)   
 	   	   	   	  endif   
 	   	   	  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  	   	  |# whina114   
 |  	   	   	  if isspace(var.whinr110.clot) and |#2043803_2.o   
 |  	   	   	  isspace(var.whinr110.serl) then |#2043803_2.o   
 	   	   	  if isspace(var.whina112.clot) and |#2043803_2.n   
 	   	   	  isspace(var.whina112.serl) then |#2043803_2.n   
 	   	   	   	  get.standard.cost.price(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  var.whina114.qstk,   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	  false)   
 	   	   	  else   
 	   	   	   	   	  	  	  	 |#2043803_2.so   
 | 	  	   	   	 if not isspace(var.whinr110.serl) then   
 | 	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 | 	   	   	   	  else   
 | 	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 | 	   	   	   	  endif  	  	 |#2043803.eo   
 	   	   	   	   	  	  	  	 |#2043803_2.sn   
 	   	   	   	 if not isspace(var.whina112.serl) then   
 	   	   	   	   	  lot.serial  =  var.whina112.serl   
 	   	   	   	  else   
 	   	   	   	   	  lot.serial  =  var.whina112.clot   
 	   	   	   	  endif  	  	 |#2043803_2.en   
 	   	   	   	  get.lot.price(  	  tdinv700.item,   
 	   	   	   	   	   	  lot.serial,   
 	   	   	   	   	   	  var.whina114.qstk,   
 	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	  false,   
 	   	   	   	   	   	  false,   
 	   	   	   	   	   	  false)   
 	   	   	  endif   
 	   	   	  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  	   	  |# whina120   
 	   	   	   	   	  hold.negative  =  hold.negative  +     
 	   	   	   	   	   	   	  remain.quan   
 	   	   	   	   	   	   	  |#2043803_2.so   
 | 	   	   	   	   	  if isspace(var.whinr110.clot) and   
 | 	   	   	   	   	  isspace(var.whinr110.serl) then   
 	  	  	  	  	  	  	  	 |#2043803_2.so   
 	   	  	  	   	  	  	  |#2043803_2.sn   
 	  	  	   	   	  if isspace(var.whina112.clot) and   
 	   	  	  	   	  isspace(var.whina112.serl) then   
 	   	  	  	   	  	  	  |#2043803_2.en   
 	   	   	   	   	   	  get.standard.cost.price(   
 	   	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	   	  remain.quan,   
 	   	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	   	  true)   
 	   	   	   	   	  else   
 	   	   	   	   	   	   	  |#2043803_2.so   
 | 	   	   	   	   	   	  if not isspace(var.whinr110.serl) then   
 | 	   	   	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 | 	   	   	   	   	   	  else   
 | 	   	   	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 | 	   	   	   	   	   	  endif   
 	   	   	   	   	   	   	  |#2043803_2.eo   
 	   	   	   	   	   	   	  |#2043803_2.sn   
 	   	   	   	   	   	  if not isspace(var.whina112.serl) then   
 	   	   	   	   	   	   	  lot.serial  =  var.whina112.serl   
 	   	   	   	   	   	  else   
 	   	   	   	   	   	   	  lot.serial  =  var.whina112.clot   
 	   	   	   	   	   	  endif   
 	   	   	   	   	   	   	  |#2043803_2.en   
 	   	   	   	   	   	  get.lot.price(  	  tdinv700.item,   
 	   	   	   	   	   	   	   	  lot.serial,   
 	   	   	   	   	   	   	   	  remain.quan,   
 	   	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	   	  true)   
 	   	   	   	   	  endif   
 	   	   	   	  endif   
 	   	   	   	  |*  corrupt data: more issued then received   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  until remain.quan  =  0   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
: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  	   	  |# whwmd255   
 	   	  hold.negative  =  0.0   
 	  endif
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:inr
:TFLNO:110
:SCPAC:ti
:SCMOD:pcs
:SFLNO:700
:ICOD:D
:QURY:START
	 orig.tipcs700.pono  =  tipcs700.pono 	  	  	  	 |*  2043803_4.n   
 	  var.whinr110.cwar  =  keep.cwar   
 	  var.whinr110.trdt  =  utc(tipcs700.trdt, 0)   
 	  hold.tipcs700.trdt  =  tipcs700.trdt   
 	  hold.tipcs700.trtm  =  tipcs700.trtm   
 	  hold.tipcs700.sern  =  tipcs700.sern   
 	  if check1.trdt  <>  tipcs700.trdt then   
 	   	  check1.trdt  =  tipcs700.trdt   
 	   	  var.whinr110.seqn  =  1   
 	  else   
 	   	  var.whinr110.seqn  =  var.whinr110.seqn  +  1   
 	  endif   
 	  var.whinr110.cprj  =  get.project(tipcs700.cprj)   
 	  if hold.cprj  <>  tipcs700.cprj or   
 	  hold.item  <>  tipcs700.item or   
 	  hold.cwar  <>  keep.cwar then   
 	   	  stock  =  0.0 	  	  	  	  	 |*  2043803_4.n 	  	    
 	   	  var.whinr110.seqn  =  1   
 	   	  var.whinr110.qhnd  =  0.0   
 	   	  hold.cprj  =  tipcs700.cprj   
 	   	  hold.item  =  tipcs700.item   
 	   	  hold.cwar  =  keep.cwar   
 | 	   	  if tdilc000.iilc  =  tcyesno.no then  	   	 |*  2043803_4.o 	    
 	   	  select  	  tipcs021.stoc:stock, tipcs021.cwar,   
 	   	  	  	  tipcs021.kltc 	  	   	 |*  2043803_4.n   
 	   	  from  	  tipcs021   
 	   	  where  	  tipcs021._index1  =  {:hold.cprj, :hold.item}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 | 	   	  else  	  	  	  	  	  	 |*  2043803_4.o 	    
 	  	  if tdilc000.iilc  =  tcyesno.yes then  	  	 |*  2043803_4.n   
 	  	  	 |*  Overwrite stock variable 	   	  	 |*  2043803_4.n   
 	   	   	  stock  =  0.0 	  	  	  	 |*  2043803_4.n 	  	    
 	   	   	  select  	  sum(tdilc101.stks):stock   
 	   	   	  from  	  tdilc101   
 | 	   	   	  where  	  tdilc101._index2  =  {:hold.cprj, :hold.item, :keep.cwar}  	  	 |*  2043803_4.o   
 	   	   	  where  	  tdilc101._index2  =  {:hold.cprj, :hold.item, "", :keep.cwar}  	 |*  2043803_4.n  	   	    
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	  endif   
 	   	  var.whina112.qskt  =  0.0   
 	   	  to.be.received  =  0.0   
 	   	  issued  =  0.0   
 	   	  i  =  1   
 	   	  dummy.receipt.qty  =  0.0   
 	   	  dummy.array.nr  =  0   
 	   	  receipt.counter  =  0   
 	   	  g.ret  =  set.mem(arr.whina112.trdt, "")    
 	   	  g.ret  =  set.mem(arr.whina112.seqn, 0)   
 	   	  g.ret  =  set.mem(arr.whina112.qskt, 0.0)   
 	   	  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   
 	   	   	  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   
 	   	   	  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  +  200   
 	   	   	   	   	  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, 0)   
 	   	   	   	  arr.whina112.seqn(i)  =  check.seqn   
 	   	   	   	  arr.whina112.qskt(i)  =  abs(curr.quan)   
 	   	   	  else   
 	   	   	   	  issued  =  issued  +  abs(curr.quan)   
 	   	   	  endif   
 	   	  endfor   
 	   	   	   	   	   	   	   	  |# 1133346.sn   
 	   	   	  determine.received.and.issued.due.to.stock.transfers(   
 	   	   	   	   	   	   	  hold.cprj,   
 	   	   	   	   	   	   	  hold.item,   
 	   	   	   	   	   	   	  hold.cwar,   
 	   	   	   	   	   	   	  received.on.stock.transfers,   
 	   	   	   	   	   	   	  issued.on.stock.transfers)   
 	   	   	   	   	   	   	   	  |# 1133346.en   
 	   	   	  total.received  =  to.be.received  +  received.on.stock.transfers   
 	   	   	  total.issued  =  issued  +  issued.on.stock.transfers   
 	   	   	   	   	   	   	   	  |# 1133346.so   
 |  	   	   	  onhand.inventory  =  max(to.be.received  -  issued, stock)   
 |  	   	   	  if onhand.inventory  >  to.be.received  -  issued then   
 	   	   	   	   	   	   	   	  |# 1133346.eo   
 	   	   	   	   	   	   	   	  |# 1133346.sn   
 	   	   	  onhand.inventory  =  max(total.received  -  total.issued, stock)   
 	   	   	  if onhand.inventory  >  to.be.received  -  issued or   
 	   	   	  received.on.stock.transfers  >  issued.on.stock.transfers then   
 	   	   	   	   	   	   	   	  |# 1133346.en   
 	   	   	   	  |*  create dummy receipt   
 	   	   	   	  dummy.receipt.qty  =  onhand.inventory  -  to.be.received  +  issued   
 	   	   	   	  if dummy.receipt.qty  =  0 then   
 	   	   	   	   	  dummy.receipt.qty  =  received.on.stock.transfers  -  issued.on.stock.transfers   
 	   	   	   	  endif   
 	   	   	   	  to.be.received  =  to.be.received  +  dummy.receipt.qty   
 	   	   	   	  i  =  1   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  array.len  =  array.len  +  200   
 	   	   	   	   	  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( date.to.num(1980,1,1), 0)   
 	   	   	   	  arr.whina112.seqn(i)  =  1  	     
 	   	   	   	  arr.whina112.qskt(i)  =  dummy.receipt.qty   
 	   	   	   	  dummy.array.nr  =  i   
 	   	   	   	  create.tipcs700.correction.record()   
 	   	   	  else   
 	   	   	   	  i  =  2   
 	   	   	  endif   
 	   	  prev.sern  =  0   
 	  endif   
 	     
 	  var.whinr110.qstk  =  tipcs700.quan   
 	  var.whinr110.bpid  =  empty()   
 	  var.whinr110.srnb  =  0   
 	  var.whinr110.shpm  =  " "   
 	  var.whinr110.shpo  =  0   
 	  var.whinr110.rcno  =  ""  	   	   	   	   	  |# 227896.sn    
 	  var.whinr110.rcln  =  0   
 	  on case tipcs700.koor   
 	   	  case tckoor.act.pur :   
 	   	   	  if not get.business.partner(tipcs700.rlcd, bcstc.orgn.suno, o.mess) then   
 	   	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	  get.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.rcno,  	   	     
 	   	   	   	  var.whinr110.rcln,  	   	     
 	   	   	   	  var.whinr110.srnb,   
 	   	   	   	  bom.line)   
 	   	   	  if tipcs700.quan  <  0 then   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	  0,  	   	   	  |*  Outbound Sequence   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	  break   
 	   	  case tckoor.act.sls :   
 	   	   	  if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	  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)   
 	   	  |*  shipment  /  line number are needed for COGS determination   
 	   	  |*  filling is conform include ibcswh0007   
 	   	   	  if tipcs700.quan  >  0 then   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  else   
 	   	   	   	   	  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  	     
 	   	   	  endif   
 	   	   	  break   
 	   	  case tckoor.sma.order :   
 	   	   	  if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	  if tipcs700.quan  >  0 then   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  0,  	   	  |*  sequence   
 	   	   	   	   	  0,  	   	  |*  Outbound Sequence   
 	   	   	   	   	  0,  	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	  break   
 	   	  case tckoor.pcs.wrh:   
 	   	   	  tipcs700.pono  =  10   
 	   	   	  var.whinr110.srnb  =  1   
 	   	   	  if tipcs700.quan  >  0 then   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  g.ret  =  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  0,  	   	  |*  sequence  	     
 	   	   	   	   	  0,  	   	  |*  Outbound Sequence   
 	   	   	   	   	  0,  	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	  break   
 	  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   
 	  |*  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   
 	  var.whinr110.clot  =  empty()   
 	  var.whinr110.serl  =  empty()   
 	  var.whina112.clot  =  empty() 	  	  	  	 |#2043803_2.n   
 	  var.whina112.serl  =  empty() 	  	  	  	 |#2043803_2.n  	    
 	  	  	  	  	  	  	  	  	 |#2043803_4.sn  	    
 	  if tipcs021.kltc  =  tckltc.batch then 	    
 	  	 determine.transaction.type.and.quantity(   
 	  	  	  	  	 tipcs700.koor,   
 	  	  	  	  	 tipcs700.cprj,   
 	  	  	  	  	 tipcs700.quan,   
 	  	  	  	  	 tipcs700.kost,   
 	  	  	  	  	 ilc.quantity, 	  	 |*  ref   
 	  	  	  	  	 ilc.transaction.type) 	 |*  ref   
 	   	  var.whinr110.clot  =  determine.lot.for.tipcs700(   
 	  	  	  	  	  	 ilc.quantity,   
 	   	  	  	  	  	 ilc.transaction.type,   
 	   	  	  	  	  	 hold.tipcs700.trdt)  	  	  	  	  	  	    
 	  endif   
 	    
 	  if tipcs021.kltc  =  tckltc.unit then 	    
 	  	 determine.transaction.type.and.quantity(   
 	  	  	  	  	 tipcs700.koor,   
 	  	  	  	  	 tipcs700.cprj,   
 	  	  	  	  	 tipcs700.quan,   
 	  	  	  	  	 tipcs700.kost,   
 	  	  	  	  	 ilc.quantity, 	  	 |*  ref   
 	  	  	  	  	 ilc.transaction.type) 	 |*  ref   
 	   	  var.whinr110.serl  =  determine.lot.for.tipcs700(   
 	  	  	  	  	  	 ilc.quantity,   
 	   	  	  	  	  	 ilc.transaction.type,   
 	   	  	  	  	  	 hold.tipcs700.trdt)   
 	  endif   
 	  	  	  	  	  	  	  	  	 |#2043803_4.en  	    
 	     
 	  dump 2  	   	  |# whinr110   
 	     
 	  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  	   	  |# whina112   
 	   	     
 	   	  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  	  |# whina114   
 	   	   	     
 	   	   	  get.customized.cost.price(tipcs700.cprj, tipcs700.item,   
 	   	   	   	   	   	   	  var.whina114.qstk, false)   
 	   	   	  if arr.whina112.qskt(i)  =  0 then   
 	   	   	   	  prev.sern  =  0   
 	   	   	   	  i  =  i  +  1   
 	   	   	  endif   
 	   	   	  if remain.quan  >  0 and arr.whina112.qskt(i)  =  0 then   
 	   	   	   	  |*  corrupt data: more issued then received   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  until remain.quan  =  0   
 	  endif
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:D
:QURY:START
	  if isspace(tdltc001.cprj) then   
 	   	  project.code  =  ""   
 	  else   
 	   	  project.code  =  get.ti.project( tdltc001.cprj)   
 	  endif   
 	  var.mwhltc100.item  =  segment.item.code(   
 	   	   	   	   	  tdltc001.item,   
 	   	   	   	   	  project.code)   
 	  if tdltc001.olot  =  tdltc.olot.purch then   
 	   	  kind.of.number  =  bcckon.act.pur   
 	  else   
 	   	  kind.of.number  =  bcckon.act.sfc   
 	  endif   
 	  var.mwhltc100.orno  =  convert.number(   
 	   	   	   	  kind.of.number,   
 	   	   	   	  tdltc001.orno)   
 	  if lot.controlled.item( tdltc001.cprj,   
 	   	   	   	  tdltc001.item) then   
 	   	  |   *  Fill dump 1 (Lot)   
 	   	  if tdltc001.olot  =  tdltc.olot.purch and   
 	   	  get.business.partner(  	  tdltc001.suno,   
 	   	   	   	   	  bcstc.orgn.suno,   
 	   	   	   	   	  errmess)  =  0 then   
 	   	   	  var.whltc100.bfbp  =  bcstc008.bpid   
 	   	  else   
 	   	   	  var.whltc100.bfbp  =  empty()   
 	   	  endif   
 	   	  if not isspace(tdltc001.revi) and   
 	   	  item.revision.is.valid(  	  tdltc001.item,   
 	   	   	   	   	  tdltc001.revi) then   
 	   	   	  var.whltc100.revi  =  tdltc001.revi   
 	   	  else   
 	   	   	  var.whltc100.revi  =  empty()   
 	   	  endif   
 	   	  |   *  Lot date  =  Date of first receipt,   
 	   	  |   *  if empty then current date   
 |  	   	  lot.date  =  tdltc001.ardt  	   	   	  |# hold.date.o   
 	   	   	   	   	   	   	   	  |# 242221.sn   
 	   	  if fifo.lifo.item(  	  tdltc001.cprj,   
 	   	   	   	   	  tdltc001.item) then   
 	   	   	  lot.date  =  tdltc001.oudt   
 	   	  else   
 	   	   	  lot.date  =  tdltc001.ardt   
 	   	  endif  	   	   	   	   	   	  |# 242221.en   
 	   	  if lot.date  =  0 then   
 	   	   	  lot.date  =  date.num()   
 	   	  endif   
 	   	  var.whltc100.ldat  =  utc(lot.date, 0)   
 	   	  Dump 1  	   	  |   *  Lots   
 	   	  if lot.price.item(  	  tdltc001.cprj,   
 	   	   	   	   	  tdltc001.item) then   
 	   	   	   	   	  	  	  	 |#10.5.2.sn   
 	  	  	 |  *  Fill Dump 5 (Lot Enterprise Units; whltc111)   
 	  	  	 |  *  For each lot a record must be created with   
 	  	  	 |  *  empty EU in case Lot Price applies   
 	  	  	 Dump 5 |  *  Lot EU's   
 	   	   	   	   	  	  	  	 |#10.5.2.en   
 	   	   	  |   *  Fill Dump 2 (Lot Price)   
 	   	   	  material.component.price(1)  =  0   
 	   	   	  material.component.price(2)  =  0   
 	   	   	  material.component.price(3)  =  0   
 	   	   	  operation.component.price(1)  =  0   
 	   	   	  operation.component.price(2)  =  0   
 	   	   	  operation.component.price(3)  =  0   
 	   	   	  surcharge.component.price(1)  =  0   
 	   	   	  surcharge.component.price(2)  =  0   
 	   	   	  surcharge.component.price(3)  =  0   
 |  	   	   	  select tdltc004.cpcp,  	   	  |# CNT.so   
 |  	   	   	   	  tdltc004.amnt  	   	  |# CNT.eo   
 	   	   	  select tdltc004.*    	   	   	  |# CNT.n   
 	   	   	  from  	  tdltc004   
 	   	   	  where  	  tdltc004._index1  =  {  	  :tdltc001.item,   
 	   	   	   	   	   	   	  :tdltc001.cntr,   
 	   	   	   	   	   	   	  :tdltc001.clot}   
 	   	   	  selectdo   
 	   	   	   	  analyze.cost.component( tdltc001.item,   
 	   	   	   	   	   	   	  tdltc001.cprj,   
 	   	   	   	   	   	   	  tdltc004.cpcp,   
 	   	   	   	   	   	   	  detail.cost.component,   
 	   	   	   	   	   	   	  material.component,   
 	   	   	   	   	   	   	  operation.component,   
 	   	   	   	   	   	   	  surcharge.component,   
 	   	   	   	   	   	   	  result)   
 	   	   	   	  on case result   
 	   	   	   	  case 0:   
 	   	   	   	   	  |   *  Cost Component in chart   
 	   	   	   	   	  |   *  Dump record   
 	   	   	   	   	  var.whltc101.cpcp  =  detail.cost.component   
 	   	   	   	   	  if is.masterdata.conversion() then   
 	   	   	   	   	   	  var.whltc101.pric(1)  =  0.0   
 	   	   	   	   	   	  var.whltc101.pric(2)  =  0.0   
 	   	   	   	   	   	  var.whltc101.pric(3)  =  0.0   
 	   	   	   	   	  else   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.so   
 |  	   	   	   	   	   	  var.whltc101.pric(1)  =  fill.mc.field.double(tdltc004.amnt, 1)   
 |  	   	   	   	   	   	  var.whltc101.pric(2)  =  fill.mc.field.double(tdltc004.amnt, 2)   
 |  	   	   	   	   	   	  var.whltc101.pric(3)  =  fill.mc.field.double(tdltc004.amnt, 3)   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.eo   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.sn   
 	   	   	   	   	   	  for i  =  1 to g.mc.depth   
 	   	   	   	   	   	   	  var.whltc101.pric(i)  =     
 	   	   	   	   	   	   	   	  get.amount.per.cost.component( "tdltc004", i)   
 	   	   	   	   	   	  endfor   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.en   
 	   	   	   	   	  endif   
 	   	   	   	   	  dump.cost.details()  	  |   *  Lot Price   
 	   	   	   	   	  break   
 	   	   	   	  case 1:   
 	   	   	   	   	  |   *  Merge to aggregated material cost component   
 	   	   	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.so   
 |  	   	   	   	   	   	  material.component.price(1)  =  material.component.price(1)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 1)   
 |  	   	   	   	   	   	  material.component.price(2)  =  material.component.price(2)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 2)   
 |  	   	   	   	   	   	  material.component.price(3)  =  material.component.price(3)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 3)   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.eo   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.sn   
 	   	   	   	   	   	  for i  =  1 to g.mc.depth   
 	   	   	   	   	   	   	  material.component.price(i)  =  material.component.price(i)  +     
 	   	   	   	   	   	   	   	  get.amount.per.cost.component( "tdltc004", i)   
 	   	   	   	   	   	  endfor   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.en   
 	   	   	   	   	  endif   
 	   	   	   	   	  break   
 	   	   	   	  case 2:   
 	   	   	   	   	  |   *  Merge to aggregated opration cost component   
 	   	   	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.so   
 |  	   	   	   	   	   	  operation.component.price(1)  =  operation.component.price(1)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 1)   
 |  	   	   	   	   	   	  operation.component.price(2)  =  operation.component.price(2)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 2)   
 |  	   	   	   	   	   	  operation.component.price(3)  =  operation.component.price(3)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 3)   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.eo   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.sn   
 	   	   	   	   	   	  for i  =  1 to g.mc.depth   
 	   	   	   	   	   	   	  operation.component.price(i)  =  operation.component.price(i)  +     
 	   	   	   	   	   	   	   	  get.amount.per.cost.component( "tdltc004", i)   
 	   	   	   	   	   	  endfor   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.en   
 	   	   	   	   	  endif   
 	   	   	   	   	  break   
 	   	   	   	  case 3:   
 	   	   	   	   	  |   *  Merge to aggregated surcharge cost component   
 	   	   	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.so   
 |  	   	   	   	   	   	  surcharge.component.price(1)  =  surcharge.component.price(1)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 1)   
 |  	   	   	   	   	   	  surcharge.component.price(2)  =  surcharge.component.price(2)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 2)   
 |  	   	   	   	   	   	  surcharge.component.price(3)  =  surcharge.component.price(3)  +     
 |  	   	   	   	   	   	   	  fill.mc.field.double(tdltc004.amnt, 3)   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.eo   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.sn   
 	   	   	   	   	   	  for i  =  1 to g.mc.depth   
 	   	   	   	   	   	   	  surcharge.component.price(i)  =  surcharge.component.price(i)  +     
 	   	   	   	   	   	   	   	  get.amount.per.cost.component( "tdltc004", i)   
 	   	   	   	   	   	  endfor   
 	   	   	   	   	   	   	   	   	   	   	   	   	  |# CNT.en   
 	   	   	   	   	  endif   
 	   	   	   	   	  break   
 	   	   	   	  endcase   
 	   	   	  endselect   
 	   	   	  var.whltc101.cpcp  =  material.component   
 	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	  var.whltc101.pric(1)  =  material.component.price(1)   
 	   	   	   	  var.whltc101.pric(2)  =  material.component.price(2)   
 	   	   	   	  var.whltc101.pric(3)  =  material.component.price(3)   
 	   	   	  else   
 	   	   	   	  var.whltc101.pric(1)  =  0   
 	   	   	   	  var.whltc101.pric(2)  =  0   
 	   	   	   	  var.whltc101.pric(3)  =  0   
 	   	   	  endif   
 	   	   	  dump.cost.details()  	  |   *  Lot Price   
 	   	   	  var.whltc101.cpcp  =  operation.component   
 	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	  var.whltc101.pric(1)  =  operation.component.price(1)   
 	   	   	   	  var.whltc101.pric(2)  =  operation.component.price(2)   
 	   	   	   	  var.whltc101.pric(3)  =  operation.component.price(3)   
 	   	   	  else   
 	   	   	   	  var.whltc101.pric(1)  =  0   
 	   	   	   	  var.whltc101.pric(2)  =  0   
 	   	   	   	  var.whltc101.pric(3)  =  0   
 	   	   	  endif   
 	   	   	  dump.cost.details()  	  |   *  Lot Price   
 	   	   	  var.whltc101.cpcp  =  surcharge.component   
 	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	  var.whltc101.pric(1)  =  surcharge.component.price(1)   
 	   	   	   	  var.whltc101.pric(2)  =  surcharge.component.price(2)   
 	   	   	   	  var.whltc101.pric(3)  =  surcharge.component.price(3)   
 	   	   	  else   
 	   	   	   	  var.whltc101.pric(1)  =  0   
 	   	   	   	  var.whltc101.pric(2)  =  0   
 	   	   	   	  var.whltc101.pric(3)  =  0   
 	   	   	  endif   
 	   	   	  dump.cost.details()  	  |   *  Lot Price   
 	   	  endif   
 	   	  |   *  Fill Dump 3 (Lot Inventory by Item and Warehouse)   
 	   	  hold.cwar  =  ""   
 	   	  var.whltc105.qhnd  =  0.0   
 	   	  var.whltc105.qblk  =  0.0   
 	   	  var.whltc105.qord  =  0.0   
 	   	  var.whltc105.qall  =  0.0   
 	   	  var.whltc105.qlal  =  0.0   
 	   	  var.whltc105.ball  =  tcyesno.no   
 	   	  var.whltc105.binb  =  tcyesno.no   
 	   	  var.whltc105.bout  =  tcyesno.no   
 	   	  var.whltc105.btri  =  tcyesno.no   
 	   	  var.whltc105.btrr  =  tcyesno.no   
 	   	  select tdilc101.*  , tcmcs003.cwar   
 	   	  from  	  tdilc101, tcmcs003   
 	   	  where  	  tdilc101._index3  =  {  	  :tdltc001.cprj,   
 	   	   	   	   	   	  :tdltc001.item,   
 	   	   	   	   	   	  :tdltc001.cntr,   
 	   	   	   	   	   	  :tdltc001.clot}   
 	   	  and  	  tcmcs003.cwar  =  tdilc101.cwar   
 	   	  and  	  tcmcs003.typw  <>  tctypw.transito   
 	   	  order by tdilc101.cprj,tdilc101.item,tdilc101.cntr,   
 	   	   	  tdilc101.clot,tdilc101.cwar   
 	   	  selectdo   
 	   	   	  var.whltc105.cwar  =  tdilc101.cwar   
 	   	   	  if hold.cwar  <>  "" and   
 	   	   	  tdilc101.cwar  <>  hold.cwar then   
 	   	   	   	  var.whltc105.cwar  =  hold.cwar   
 	   	   	   	  var.whltc105.trdt  =  hold.trdt  	   	  |# 1160966.n   
 |  	   	   	   	  if tdilc101.date  =  0 then  	   	  |# 1160966.so   
 |  	   	   	   	   	  var.whltc105.trdt  =  tdltc001.ardt   
 |  	   	   	   	  else   
 |  	   	   	   	   	  var.whltc105.trdt  =  tdilc101.date   
 |  	   	   	   	  endif  	   	   	   	  |# 1160966.eo   
 	   	   	   	  if not is.masterdata.conversion() then  	  |# 1160966.n   
 	   	   	   	   	  |   *  Subtract location allocated quantity   
 	   	   	   	   	  |   *  from allocated and on order   
 	   	   	   	   	  determine.location.allocated.quantity(   
 	   	   	   	   	   	   	  var.whltc105.cwar,   
 	   	   	   	   	   	   	  tdltc001.cprj,   
 	   	   	   	   	   	   	  tdltc001.item,   
 	   	   	   	   	   	   	  tdltc001.clot,   
 	   	   	   	   	   	   	  location.allocated.quantity)   
 	   	   	   	   	  var.whltc105.qall  =  var.whltc105.qall  -     
 	   	   	   	   	   	   	  location.allocated.quantity   
 	   	   	   	   	  var.whltc105.qord  =  var.whltc105.qord  -     
 	   	   	   	   	   	   	  location.allocated.quantity   
 	   	   	   	   	  var.whltc105.qlal  =  location.allocated.quantity   
 	   	   	   	  endif  	   	   	   	   	  |# 1160966.n   
 	   	   	   	  Dump 3  	  |   *  Lot Inventory   
 	   	   	   	  var.whltc105.qhnd  =  0.0   
 	   	   	   	  var.whltc105.qblk  =  0.0   
 	   	   	   	  var.whltc105.qord  =  0.0   
 	   	   	   	  var.whltc105.qall  =  0.0   
 	   	   	   	  var.whltc105.qlal  =  0.0   
 	   	   	  endif   
 	   	   	  |   *  Cumulate quantities by warehouse   
 	   	   	  if not is.masterdata.conversion() then   
 	   	   	   	  var.whltc105.qhnd  =  var.whltc105.qhnd  +     
 	   	   	   	   	   	   	  tdilc101.stks   
 	   	   	   	  determine.blocked.quantity(   
 	   	   	   	   	   	  tdilc101.cwar,   
 	   	   	   	   	   	  tdilc101.loca,   
 	   	   	   	   	   	  "", |   *   Project   
 	   	   	   	   	   	  tdilc101.item,   
 	   	   	   	   	   	  tdilc101.clot,   
 	   	   	   	   	   	  tdilc101.date,   
 	   	   	   	   	   	  tdilc101.stun,   
 	   	   	   	   	   	  tdilc101.strb,   
 	   	   	   	   	   	  tdilc101.stra,   
 	   	   	   	   	   	  process.blocked,   
 	   	   	   	   	   	  manual.blocked)   
 	   	   	   	  var.whltc105.qblk  =  var.whltc105.qblk  +     
 	   	   	   	   	   	   	  process.blocked  +  manual.blocked   
 	   	   	   	  var.whltc105.qall  =  var.whltc105.qall  +     
 	   	   	   	   	   	   	  tdilc101.stka   
 	   	   	   	  var.whltc105.qord  =  var.whltc105.qord  +     
 	   	   	   	   	   	   	  tdilc101.stko   
 	   	   	   	  var.whltc105.ball  =  tdltc001.blst   
 	   	   	   	  var.whltc105.binb  =  tdltc001.inbl   
 	   	   	   	  var.whltc105.bout  =  tdltc001.outb   
 	   	   	   	  var.whltc105.btri  =  tdltc001.trsb   
 	   	   	   	  var.whltc105.btrr  =  tcyesno.no   
 	   	   	  endif   
 	   	   	  hold.cwar  =  tdilc101.cwar   
 	   	   	  if tdilc101.date  =  0 then  	   	   	  |# 1160966.sn   
 	   	   	   	  hold.trdt  =  tdltc001.ardt   
 	   	   	  else   
 	   	   	   	  hold.trdt  =  tdilc101.date   
 	   	   	  endif  	   	   	   	   	   	  |# 1160966.en   
 	   	  selecteos   
 	   	   	  var.whltc105.cwar  =  hold.cwar   
 |  	   	   	  var.whltc105.trdt  =  tdilc101.date  	   	  |# 1160966.o   
 	   	   	  var.whltc105.trdt  =  hold.trdt  	   	   	  |# 1160966.n   
 	   	   	  Dump 3  	   	  |   *  Lot Inventory   
 	   	  endselect   
 	  endif   
 	  if serialized.item(  	  tdltc001.cprj,   
 	   	   	   	  tdltc001.item) then   
 	   	  |   *  Fill Dump 4 (Serials)   
 	   	  if tdltc001.olot  =  tdltc.olot.purch and   
 	   	  get.business.partner( tdltc001.suno,   
 	   	   	   	   	  bcstc.orgn.suno,   
 	   	   	   	   	  errmess)  =  0 then   
 	   	   	  var.whltc500.bpid  =  bcstc008.bpid   
 	   	  else   
 	   	   	  var.whltc500.bpid  =  empty()   
 	   	  endif   
 	   	  if not isspace(tdltc001.revi) and   
 	   	  item.revision.is.valid(  	  tdltc001.item,   
 	   	   	   	   	  tdltc001.revi) then   
 	   	   	  var.whltc500.revi  =  tdltc001.revi   
 	   	  else   
 	   	   	  var.whltc500.revi  =  empty()   
 	   	  endif   
 |  	   	  |   *  Inventory date  	   	   	   	   	   	  |# 245090.so   
 |  	   	  if fifo.lifo.item(  	  tdltc001.cprj,   
 |  	   	   	   	   	  tdltc001.item) then   
 |  	   	   	  if tdltc001.ardt  <>  0 then   
 |  	   	   	   	  inventory.date  =  tdltc001.ardt   
 |  	   	   	  else   
 |  	   	   	   	  inventory.date  =  date.num()   
 |  	   	   	  endif   
 |  	   	  else   
 |  	   	   	  inventory.date  =  0   
 |  	   	  endif  	   	   	   	   	   	   	  |# 245090.eo   
 	   	  |   *  Inventory date  	   	   	   	   	   	  |# 245090.sn   
 	   	  if fifo.lifo.item(  	  tdltc001.cprj,   
 	   	   	   	   	  tdltc001.item) then   
 	   	   	  if tdltc001.oudt  <>  0 then   
 	   	   	   	  inventory.date  =  tdltc001.oudt   
 	   	   	  else   
 	   	   	   	  inventory.date  =  tdltc001.ardt   
 	   	   	  endif   
 	   	   	  if inventory.date  =  0 then   
 	   	   	   	  inventory.date  =  date.num()   
 	   	   	  endif   
 	   	  else   
 	   	   	  inventory.date  =  0   
 	   	  endif   
 	   	   	   	   	   	   	   	   	   	  |# 245090.en   
 	   	  var.whltc500.idat  =  utc(inventory.date, 0)   
 	   	  last.inspection.date  =  0   
 	   	  select tdilc101.*  , tcmcs003.cwar   
 	   	  from  	  tdilc101, tcmcs003   
 	   	  where  	  tdilc101._index3  =  {  	  :tdltc001.cprj,   
 	   	   	   	   	   	  :tdltc001.item,   
 	   	   	   	   	   	  :tdltc001.cntr,   
 	   	   	   	   	   	  :tdltc001.clot}   
 	   	  and  	  tcmcs003.cwar  =  tdilc101.cwar   
 	   	  and  	  tcmcs003.typw  <>  tctypw.transito   
 	   	  selectdo   
 	   	   	  if tdilc101.stro  >  0.0 then   
 	   	   	   	  |   *  Check whether OnHand is on other location   
 	   	   	   	  if serial.on.other.location() then   
 	   	   	   	   	  continue   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	  var.whltc500.cwar  =  tdilc101.cwar  	   	  |# 245164.n   
 	   	   	  var.whltc500.loca  =  tdilc101.loca  	   	  |# 245164.n   
 	   	   	  last.inspection.date  =  max(last.inspection.date, tdilc101.lsid)   
 	   	   	  var.whltc500.lsid  =  utc(last.inspection.date, 0)   
 	   	   	  if is.masterdata.conversion() then   
 	   	   	   	  var.whltc500.qhnd  =  0.0   
 	   	   	   	  var.whltc500.qblk  =  0.0   
 	   	   	   	  var.whltc500.qall  =  0.0   
 	   	   	   	  var.whltc500.qord  =  0.0   
 	   	   	   	  var.whltc500.qlal  =  0.0   
 	   	   	   	  var.whltc500.ball  =  tcyesno.no  	  |   *  target   
 	   	   	   	  var.whltc500.bout  =  tcyesno.no  	  |   *  target   
 	   	   	   	  var.whltc500.btri  =  tcyesno.no  	  |   *  target   
 	   	   	  else   
 	   	   	   	  var.whltc500.qhnd  =  tdilc101.stks   
 	   	   	   	  var.whltc500.qblk  =  tdilc101.stkb   
 	   	   	   	  var.whltc500.qall  =  tdilc101.stka   
 	   	   	   	  var.whltc500.qord  =  tdilc101.stko   
 	   	   	   	  var.whltc500.qlal  =  tdilc101.stka   
 	   	   	   	  var.whltc500.ball  =  tdilc101.blst   
 	   	   	   	  var.whltc500.bout  =  tdilc101.outb   
 	   	   	   	  var.whltc500.btri  =  tdilc101.trfb   
 	   	   	  endif   
 	   	   	  set.serial.ownership(var.whltc500.qhnd)  	  	 |#1858553.n   
 	   	   	  Dump 4  	   	  |   *  Serials   
 	   	  selectempty   
 |  	   	   	   	   	   	   	  |# 245164.sn |# 1376637.so   
 |  	   	   	  |# if the stock record for the serial cannot be found the   
 |  	   	   	  |# warehouse is taken from the item (tiitm001)   
 |  	   	   	  |# the location field is left empty.   
 |  	   	   	  get.item.default.warehouse(tdltc001.item)   
 |  	   	   	  var.whltc500.loca  =  " "  	  |# 245164.en |# 1376637.eo   
 	   	   	   	   	   	   	   	   	   	  |# 1376637.sn   
 	   	   	  |   *  If the stock record for the serial cannot be found the   
 	   	   	  |   *  warehouse is taken from the item (tiitm001) or in case   
 	   	   	  |   *  the project field is filled the warehouse is retrieved   
 	   	   	  |   *  from the customized item table (tipcs021)   
 	   	   	  |   *  In both cases the location field is left empty.   
 	   	   	  get.item.default.warehouse(tdltc001.cprj, tdltc001.item)   
 	   	   	  var.whltc500.loca  =  " "  	   	   	   	  |# 1376637.en   
 	   	   	  if is.masterdata.conversion() then   
 	   	   	   	  var.whltc500.qhnd  =  0.0   
 	   	   	   	  var.whltc500.qblk  =  0.0   
 	   	   	   	  var.whltc500.qall  =  0.0   
 	   	   	   	  var.whltc500.qord  =  0.0   
 	   	   	   	  var.whltc500.qlal  =  0.0   
 	   	   	   	  var.whltc500.ball  =  tcyesno.no  	  |   *  target   
 	   	   	   	  var.whltc500.bout  =  tcyesno.no  	  |   *  target   
 	   	   	   	  var.whltc500.btri  =  tcyesno.no  	  |   *  target   
 	   	   	  else   
 	   	   	   	  var.whltc500.qhnd  =  tdltc001.stoc   
 	   	   	   	  var.whltc500.qblk  =  tdltc001.bloc   
 	   	   	   	  var.whltc500.qall  =  tdltc001.allo   
 	   	   	   	  var.whltc500.qord  =  tdltc001.ordr   
 	   	   	   	  var.whltc500.qlal  =  tdltc001.allo   
 	   	   	   	  var.whltc500.ball  =  tcyesno.no  	  |   *  target   
 	   	   	   	  var.whltc500.bout  =  tcyesno.no  	  |   *  target   
 	   	   	   	  var.whltc500.btri  =  tcyesno.no  	  |   *  target   
 	   	   	  endif   
 	   	   	  set.serial.ownership(var.whltc500.qhnd)  	  	 |#1858553.n   
 	  	  	  var.whltc500.lsid  =  utc(0, 0) 	  	  	 |#1898316.n   
 	   	   	  Dump 4  	   	  |   *  Serials   
 	   	  endselect   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:S
:QURY:START
select  	  tdltc001.*     
from 	  tdltc001
where 	  tdltc001.cntr  =  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:ltc
:TFLNO:100
:SCPAC:td
:SCMOD:ltc
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:60
:VERS:B4st
:RELE:61
:CUST:f106
:TCPAC:wh
:TCMOD:wmd
:TFLNO:000
:SCPAC:td
:SCMOD:ilc
:SFLNO:000
:ICOD:S
:QURY:START
select 	 tdilc000.*    
from 	 tdilc000
:QURY:END
:TEXT:

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

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

:TEXT:END
