QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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   
 	  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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:D
:QURY:START
var.tfcat000.indt =  utc(0, 0)  
 var.tfcat000.dsca =  form.text$("bcstc00035") | *  Actual Set  
 dump 1  
 var.tfcat000.indt =  utc(date.num(), time.num())  
 var.tfcat000.dsca =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:S
:QURY:START
select ctcat001
from ctcat001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:004
:SCPAC:ct
:SCMOD:cat
:SFLNO:050
:ICOD:D
:QURY:START
	 on case ctcat050.cpor  
 	 	 case ctcat.cpor.bdev:  
 	 	 	 var.tfcat004.cpor =  1 	 	 | tfcat.cpor.odev  
 	 	 	 break  
 	 	 case ctcat.cpor.vdev:  
 	 	 	 var.tfcat004.cpor =  2 	 	 |tfcat.cpor.cdev  
 	 	 	 break  
 	 	 case ctcat.cpor.udev:  
 	 	 	 var.tfcat004.cpor =  3 	 	 |tfcat.cpor.ouco  
 	 	 	 break  
 	 	 case ctcat.cpor.cfix:  
 	 	 	 var.tfcat004.cpor =  4 	 	 |tfcat.cpor.cfix  
 	 	 	 break  
 	 	 case ctcat.cpor.call:  
 	 	 	 var.tfcat004.cpor =  5 | 	 	 tfcat.cpor.call  
 	 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:004
:SCPAC:ct
:SCMOD:cat
:SFLNO:050
:ICOD:S
:QURY:START
select 	 ctcat050.*
from ctcat050
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:004
:SCPAC:ct
:SCMOD:cat
:SFLNO:050
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:210
:SCPAC:ct
:SCMOD:cat
:SFLNO:220
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:210
:SCPAC:ct
:SCMOD:cat
:SFLNO:220
:ICOD:S
:QURY:START
select 	 ctcat220.*
from ctcat220
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:210
:SCPAC:ct
:SCMOD:cat
:SFLNO:220
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:211
:SCPAC:ct
:SCMOD:cat
:SFLNO:221
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:211
:SCPAC:ct
:SCMOD:cat
:SFLNO:221
:ICOD:S
:QURY:START
select 	 ctcat221.*
from ctcat221
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:211
:SCPAC:ct
:SCMOD:cat
:SFLNO:221
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:220
:SCPAC:ct
:SCMOD:cat
:SFLNO:210
:ICOD:D
:QURY:START
	 on case ctcat210.rtyp  
 	 	 case ctcat.rtyp.performance:  
 	 	 	 var.tfcat220.pqan =  ctcat210.perf  
 	 	 	 break  
 	 	 case ctcat.rtyp.balance:  
 	 	 	 var.tfcat220.pqan =  0.0  
 	 	 	 break  
 	 	 case ctcat.rtyp.allocation:  
 	 	 	 var.tfcat220.pqan =  ctcat210.yper  
 	 	 	 break  
 	 endcase  
 	 	  
 	 if ctcat210.pdfa <=  1 then  
 	 	 var.tfcat220.pdpe =  ctcat210.pdfa *  100  
 	 else  
 	 	 if ctcat210.year <>  prev.year then  
 	 	 	 select 	 count( *  ):no.of.periods  
 	 	 	 from 	 tfgld005  
 	 	 	 where 	 tfgld005.ptyp =  tfgld.ptyp.financial  
 	 	 	 and 	 tfgld005.year =  :ctcat210.year  
 	 	 	 and 	 tfgld005.corr =  tcyesno.no  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 endselect  
 	 	 	 prev.year =  ctcat210.year  
 	 	 	 var.tfcat220.pdpe =  (ctcat210.pdfa *  100) /  no.of.periods  
 	 	 endif  
 	 endif  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:220
:SCPAC:ct
:SCMOD:cat
:SFLNO:210
:ICOD:S
:QURY:START
select 	 ctcat210.*
from ctcat210
order by ctcat210.year
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:220
:SCPAC:ct
:SCMOD:cat
:SFLNO:210
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:221
:SCPAC:ct
:SCMOD:cat
:SFLNO:215
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:240
:SCPAC:ct
:SCMOD:cat
:SFLNO:320
:ICOD:D
:QURY:START
	 if ctcat320.budg =  ctcat001.budg then  
 	 	 select 	 ctcat330.post  
 	 	 from 	 ctcat330  
 	 	 where 	 ctcat330._index1 =  {:ctcat320.year,  
 	 	 	 	 	 :ctcat320.prod,  
 	 	 	 	 	 :ctcat320.dtyp,  
 	 	 	 	 	 :ctcat320.dimx}  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if ctcat330.post =  empty then  
 	 	 	 	 var.tfcat240.post =  tcyesno.no  
 	 	 	 else  
 	 	 	 	 var.tfcat240.post =  ctcat330.post  
 	 	 	 endif  
 	 	 selectempty  
 	 	 	 var.tfcat240.post =  tcyesno.no  
 	 	 endselect  
 	 else  
 	 	 var.tfcat240.post =  tcyesno.no  
 	 endif  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:240
:SCPAC:ct
:SCMOD:cat
:SFLNO:320
:ICOD:S
:QURY:START
select 	 ctcat320.*
from ctcat320
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:240
:SCPAC:ct
:SCMOD:cat
:SFLNO:320
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:400
:ICOD:D
:QURY:START
	 var.tfcat400.igld =  tcyesno.no  
 	 var.tfcat400.icat =  tcyesno.no  
 	 var.tfcat400.ifbs =  tcyesno.no  
 	 var.tfcat400.pdpe =  0.0  
 	 select ctcat015.rtyp  
 	 from ctcat015  
 	 where ctcat015._index1 =  {:ctcat400.sdty,  
 	 	 	 	 :ctcat400.sdim,  
 	 	 	 	 :ctcat400.sref}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tfcat400.pdpe =  100  
 	 	 else  
 	 	 	 var.tfcat400.pdpe =  0.0  
 	 	 endif  
 	 endselect  
 	 on case ctcat400.fvfp  
 	 	 case ctcat.fvfi.full:  
 	 	 	 var.tfcat400.valp =  3  
 	 	 	 break  
 	 	 case ctcat.fvfi.variable:  
 	 	 	 var.tfcat400.valp =  2  
 	 	 	 break  
 	 	 case ctcat.fvfi.fix:  
 	 	 	 var.tfcat400.valp =  1  
 	 	 	 break  
 	 	 default:  
 	 	 	 var.tfcat400.valp =  3  
 	 endcase  
 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 var.cini =  1 	 | *  tfcat.cini  
 	 else  
 	 	 var.cini =  4 	 | *  tfcat.none  
 	 endif  
 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 var.tfcat400.ifbs =  tcyesno.yes  
 	 endif  
 dump 400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:400
:ICOD:S
:QURY:START
select 	 ctcat400.*
from 	 ctcat400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:401
:ICOD:D
:QURY:START
	 var.tfcat400.igld =  tcyesno.no  
 	 var.tfcat400.icat =  tcyesno.no  
 	 var.tfcat400.ifbs =  tcyesno.no  
 	 var.tfcat400.pdpe =  0.0  
 	 select 	 ctcat400.disb,ctcat400.coca,  
 	 	 ctcat400.slea,ctcat400.cint  
 	 from ctcat400  
 	 where ctcat400._index1 =  {:ctcat401.year,  
 	 	 	 	 :ctcat401.budg,  
 	 	 	 	 :ctcat401.tdty,  
 	 	 	 	 :ctcat401.tdim,  
 	 	 	 	 :ctcat401.tref,  
 	 	 	 	 :ctcat401.tlea,  
 	 	 	 	 :ctcat401.sdty,  
 	 	 	 	 :ctcat401.sdim,  
 	 	 	 	 :ctcat401.sref,  
 	 	 	 	 :ctcat401.sern}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tfcat400.disb =  ctcat400.disb  
 	 	 var.tfcat400.coca =  ctcat400.coca  
 	 	 var.tfcat400.slea =  ctcat400.slea  
 	 	 var.tfcat400.dvar =  ctcat400.tpor  
 	 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 	 var.cini =  1 	 | *  tfcat.cini.fbs  
 	 	 else  
 	 	 	 var.cini =  4 	 | *  tfcat.cini.none  
 	 	 endif  
 	 	 if ctcat400.cint =  tcyesno.yes then  
 	 	 	 var.tfcat400.ifbs =  tcyesno.yes  
 	 	 endif  
 	 	 on case ctcat400.fvfp  
 	 	 	 case ctcat.fvfi.full:  
 	 	 	 	 var.tfcat400.valp =  3  
 	 	 	 	 break  
 	 	 	 case ctcat.fvfi.variable:  
 	 	 	 	 var.tfcat400.valp =  2  
 	 	 	 	 break  
 	 	 	 case ctcat.fvfi.fix:  
 	 	 	 	 var.tfcat400.valp =  1  
 	 	 	 	 break  
 	 	 	 default:  
 	 	 	 	 var.tfcat400.valp =  3  
 	 	 endcase  
 	 endselect  
 	 select ctcat015.rtyp  
 	 from ctcat015  
 	 where ctcat015._index1 =  {:ctcat401.sdty,  
 	 	 	 	 :ctcat401.sdim,  
 	 	 	 	 :ctcat401.sref}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tfcat400.pdpe =  ctcat401.pdfa  
 	 	 else  
 	 	 	 var.tfcat400.pdpe =  0.0  
 	 	 endif  
 	 endselect  
 	 dump 401
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:401
:ICOD:S
:QURY:START
select 	 ctcat401.*
from 	 ctcat401
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:401
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:500
:ICOD:D
:QURY:START
	 var.tfcat400.igld =  tcyesno.no  
 	 var.tfcat400.icat =  tcyesno.no  
 	 var.tfcat400.ifbs =  tcyesno.no  
 	 var.tfcat400.pdpe =  0.0  
 	 select ctcat015.rtyp  
 	 from ctcat015  
 	 where ctcat015._index1 =  {:ctcat500.sdty,  
 	 	 	 	 :ctcat500.sdim,  
 	 	 	 	 :ctcat500.sref}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tfcat400.pdpe =  ctcat500.pdfa  
 	 	 else  
 	 	 	 var.tfcat400.pdpe =  0  
 	 	 endif  
 	 endselect  
 	 on case ctcat500.fvfp  
 	 	 case ctcat.fvfi.full:  
 	 	 	 var.tfcat400.valp =  3 	 | *  tfcat.valp.total  
 	 	 	 break  
 	 	 case ctcat.fvfi.variable:  
 	 	 	 var.tfcat400.valp =  2 	 | *  tfcat.valp.variable  
 	 	 	 break  
 	 	 case ctcat.fvfi.fix:  
 	 	 	 var.tfcat400.valp =  1 	 | *  tfcat.valp.fixed  
 	 	 	 break  
 	 	 default:  
 	 	 	 var.tfcat400.valp =  3  
 	 endcase  
 	 if ctcat500.cint =  tcyesno.yes then  
 	 	 var.cini =  2 	 | *  tfcat.cini.cat  
 	 else  
 	 	 var.cini =  4 	 | *  tfcat.cini.none  
 	 endif  
 	 if ctcat500.cint =  tcyesno.yes then  
 	 	 var.tfcat400.icat =  tcyesno.yes  
 	 endif  
 	 dump 500
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:500
:ICOD:S
:QURY:START
select 	 ctcat500.*
from 	 ctcat500
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:400
:SCPAC:ct
:SCMOD:cat
:SFLNO:500
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:412
:SCPAC:ct
:SCMOD:cat
:SFLNO:412
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:412
:SCPAC:ct
:SCMOD:cat
:SFLNO:412
:ICOD:S
:QURY:START
select 	 ctcat412.*
from ctcat412
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cat
:TFLNO:412
:SCPAC:ct
:SCMOD:cat
:SFLNO:412
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:D
:QURY:START
	 var.tffbs000.indt =  utc(0, 0)  
 	 var.str.tffbs000.dsca =  form.text$("bcstc00035") | *  Actual Set  
 	 dump 1  
 	 var.tffbs000.indt =  utc(date.num(), time.num())  
 	 var.str.tffbs000.dsca =  form.text$("bcstc00036") | *  Converted from Baan IVc4  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:S
:QURY:START
select 	 ctcat001.*
from ctcat001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:000
:SCPAC:ct
:SCMOD:cat
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:003
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:D
:QURY:START
	 select 	 ctcat110.budg  
 	 from 	 ctcat110  
 	 where 	 ctcat110.budg =  :tffbs003.budg  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tffbs003.sdbu =  tcyesno.yes  
 	 selectempty  
 	 	 var.tffbs003.sdbu =  tcyesno.no  
 	 endselect  
 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:003
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:S
:QURY:START
select tffbs003.*
from tffbs003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:003
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:005
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:D
:QURY:START
	   get.year.range.for.budget(   	      	      	      	     |    #  1150172.sn   
 	      	   tffbs003.budg,   
 	      	   var.first.year,   	      	     |    *  ref   
 	      	   var.last.year)   	      	     |    *  ref   	      	      	     |    #  1150172.en   
 	   var.main.budget.year  =  var.first.year   
 	   for var.main.budget.year  =  var.first.year to var.last.year   
 	      	   if previous.budget  <>  tffbs003.budg then   
 	      	      	   var.parent.budget.year  =  var.main.budget.year   
 	      	      	   var.comparison.budget.year  =  var.main.budget.year   
 	      	      	   var.derived.budget.year  =  var.main.budget.year   
 	      	      	   if isspace(tffbs003.pbud) then   
 	      	      	      	   var.parent.budget.year  =  0   
 	      	      	   endif   
 	      	      	   if isspace(tffbs003.cobu) then   
 	      	      	      	   var.comparison.budget.year  =  0   
 	      	      	   endif   
 	      	      	   if isspace(tffbs003.dbud) then   
 	      	      	      	   var.derived.budget.year  =  0   
 	      	      	   endif   
 	      	      	   previous.budget  =  tffbs003.budg   
 	      	   endif   
 	      	   get.budget.definitive.status(   
 	      	      	      	      	      	   var.main.budget.year,   
 	      	      	      	      	      	   tffbs003.budg)   
 	      	   dump 005  |    *  tffbs005   
 	      	   select tffbs004.*     
 	      	   from   	   tffbs004   
 	      	   where   	   tffbs004.budg  =  :tffbs003.budg   
 	      	   selectdo   
 	      	      	   dump 004  |    *  tffbs004   
 	      	   endselect   
 	      	      	      	      	      	      	      	     |    #  1042971.so   
 |     	      	   var.main.budget.year  =  var.main.budget.year  +  1   
 	      	      	      	      	      	      	      	     |    #  1042971.eo   
 	   endfor
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:005
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:S
:QURY:START
select   	   tffbs003.*
from 	   tffbs003
order by tffbs003._index1   	      	      	      	      	     |    #  1042971.n
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:005
:SCPAC:tf
:SCMOD:fbs
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:010
:SCPAC:ct
:SCMOD:cat
:SFLNO:002
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat002  
 	 on case 	 ctcat002.dtyp  
 	 	 case 	 1:  
 	 	 	 var.tffbs010.adt1 =  1  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 2:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  1  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 3:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  1  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 4:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  1  
 	 	 	 var.tffbs010.adt5 =  2  
 	 	 	 break  
 	 	 case 	 5:  
 	 	 	 var.tffbs010.adt1 =  2  
 	 	 	 var.tffbs010.adt2 =  2  
 	 	 	 var.tffbs010.adt3 =  2  
 	 	 	 var.tffbs010.adt4 =  2  
 	 	 	 var.tffbs010.adt5 =  1  
 	 	 	 break  
 	 endcase  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:010
:SCPAC:ct
:SCMOD:cat
:SFLNO:002
:ICOD:S
:QURY:START
select 	 ctcat002.*
from ctcat002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:010
:SCPAC:ct
:SCMOD:cat
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:011
:SCPAC:ct
:SCMOD:cat
:SFLNO:003
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:011
:SCPAC:ct
:SCMOD:cat
:SFLNO:003
:ICOD:S
:QURY:START
select 	 ctcat003.*
from ctcat003
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:011
:SCPAC:ct
:SCMOD:cat
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:012
:SCPAC:ct
:SCMOD:cat
:SFLNO:004
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:012
:SCPAC:ct
:SCMOD:cat
:SFLNO:004
:ICOD:S
:QURY:START
select 	 ctcat004.*
from ctcat004
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:012
:SCPAC:ct
:SCMOD:cat
:SFLNO:004
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:020
:SCPAC:ct
:SCMOD:cat
:SFLNO:010
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:020
:SCPAC:ct
:SCMOD:cat
:SFLNO:010
:ICOD:S
:QURY:START
select 	 ctcat010.*
from ctcat010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:020
:SCPAC:ct
:SCMOD:cat
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:021
:SCPAC:ct
:SCMOD:cat
:SFLNO:021
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:021
:SCPAC:ct
:SCMOD:cat
:SFLNO:021
:ICOD:S
:QURY:START
select 	 ctcat021.*
from ctcat021
where 	 ctcat021.mult <=  1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:021
:SCPAC:ct
:SCMOD:cat
:SFLNO:021
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:030
:SCPAC:ct
:SCMOD:cat
:SFLNO:015
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat015  
 	 on case ctcat015.rtyp  
 	 case ctcat.rtyp.performance:  
 	 	 	 var.tffbs030.rtyp =  2 	 | *  tfffbs.rtyp.quan  
 	 	 	 var.tffbs030.slea =  empty.string(1;12)  
 	 	 	 var.tffbs030.pdpa =  2 	 | *  tcyesno.no  
 	 	 	 break  
 	 	 case ctcat.rtyp.balance:  
 	 	 	 var.tffbs030.rtyp =  1 	 | *  tffbs.rtyp.amount  
 	 	 	 var.tffbs030.slea =  ctcat015.leac  
 	 	 	 var.tffbs030.pdpa =  2 	 | *  tcyesno.no  
 	 	 	 break  
 	 	 case ctcat.rtyp.allocation:  
 	 	 	 var.tffbs030.rtyp =  2 	 | *  tffbs.rtyp.quan  
 	 	 	 var.tffbs030.slea =  empty.string(1;12)  
 	 	 	 var.tffbs030.pdpa =  1 	 | *  tcyesno.yes  
 	 	 	 break  
 	 endcase  
 	 on case ctcat015.kopl  
 	 	 case ctcat.kopl.progressive:  
 	 	 	 var.tffbs030.ptyp =  1 	 | *  tfffbs.ptyp.progressive  
 	 	 	 break  
 	 	 case ctcat.kopl.retrograde:  
 	 	 	 var.tffbs030.ptyp =  2 	 | *  tffbs.ptyp.retrograde  
 	 	 	 break  
 	 endcase  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:030
:SCPAC:ct
:SCMOD:cat
:SFLNO:015
:ICOD:S
:QURY:START
select 	 ctcat015.*
from ctcat015
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:030
:SCPAC:ct
:SCMOD:cat
:SFLNO:015
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:040
:SCPAC:ct
:SCMOD:cat
:SFLNO:014
:ICOD:D
:QURY:START
	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:040
:SCPAC:ct
:SCMOD:cat
:SFLNO:014
:ICOD:S
:QURY:START
select 	 ctcat014.*
from ctcat014
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:040
:SCPAC:ct
:SCMOD:cat
:SFLNO:014
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:041
:SCPAC:ct
:SCMOD:cat
:SFLNO:012
:ICOD:D
:QURY:START
	 on case ctcat012.lasu  
 	 	 case ctcat.lasu.leac:  
 	 	 	 var.tffbs041.ltyp =  1 	 | *  tffbs.ltyp.leac  
 	 	 	 break  
 	 	 case ctcat.lasu.sum:  
 	 	 	 var.tffbs041.ltyp =  2 	 | *  tffbs.ltyp.sum  
 	 	 	 break  
 	 endcase  
 	 | *  Dump records from ctcat012  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:041
:SCPAC:ct
:SCMOD:cat
:SFLNO:012
:ICOD:S
:QURY:START
select 	 ctcat012.*
from ctcat012
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:041
:SCPAC:ct
:SCMOD:cat
:SFLNO:012
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:042
:SCPAC:ct
:SCMOD:cat
:SFLNO:013
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat013  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:042
:SCPAC:ct
:SCMOD:cat
:SFLNO:013
:ICOD:S
:QURY:START
select 	 ctcat013.*
from ctcat013
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:042
:SCPAC:ct
:SCMOD:cat
:SFLNO:013
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:100
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:S
:QURY:START
select 	 tffbs101.*
from 	 tffbs101
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:100
:SCPAC:tf
:SCMOD:fbs
:SFLNO:101
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:110
:SCPAC:ct
:SCMOD:cat
:SFLNO:110
:ICOD:D
:QURY:START
	 if ctcat110.gful <>  0 then  
 	 	 var.tffbs110.brat =  ctcat110.pful /  ctcat110.gful  
 	 else  
 	 	 var.tffbs110.brat =  0  
 	 endif  
 	 | *  Dump records from ctcat110  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:110
:SCPAC:ct
:SCMOD:cat
:SFLNO:110
:ICOD:S
:QURY:START
select 	 ctcat110.*
from ctcat110
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:110
:SCPAC:ct
:SCMOD:cat
:SFLNO:110
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:111
:SCPAC:ct
:SCMOD:cat
:SFLNO:120
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat120  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:111
:SCPAC:ct
:SCMOD:cat
:SFLNO:120
:ICOD:S
:QURY:START
select 	 ctcat120.*
from ctcat120
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:111
:SCPAC:ct
:SCMOD:cat
:SFLNO:120
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:120
:SCPAC:ct
:SCMOD:cat
:SFLNO:111
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat111  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:120
:SCPAC:ct
:SCMOD:cat
:SFLNO:111
:ICOD:S
:QURY:START
select 	 ctcat111.*
from ctcat111
where ctcat111.refu <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:120
:SCPAC:ct
:SCMOD:cat
:SFLNO:111
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:121
:SCPAC:ct
:SCMOD:cat
:SFLNO:121
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat121  
 	 var.tffbs121.pdpe =  0.0  
 	 select 	 ctcat015.rtyp  
 	 from 	 ctcat015  
 	 where 	 ctcat015._index1 =  {:ctcat121.dtyp,  
 	 	 	 	 :ctcat121.dimx,  
 	 	 	 	 :ctcat121.refu}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 if ctcat015.rtyp =  ctcat.rtyp.allocation then  
 	 	 	 var.tffbs121.pdpe =  ctcat121.pdfa *  100  
 	 	 else  
 	 	 	 var.tffbs121.pdpe =  0.0  
 	 	 endif  
 	 endselect  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:121
:SCPAC:ct
:SCMOD:cat
:SFLNO:121
:ICOD:S
:QURY:START
select 	 ctcat121.*
from ctcat121
where ctcat121.refu <>  ""
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:121
:SCPAC:ct
:SCMOD:cat
:SFLNO:121
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:130
:SCPAC:ct
:SCMOD:cat
:SFLNO:130
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat130  
 	 	 	  
 	 var.cprj =  string.set$(" ",9)  
 	 var.tffbs130.item =  segment.item.code(ctcat130.item,var.cprj)  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:130
:SCPAC:ct
:SCMOD:cat
:SFLNO:130
:ICOD:S
:QURY:START
select 	 ctcat130.*
from ctcat130
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:130
:SCPAC:ct
:SCMOD:cat
:SFLNO:130
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:131
:SCPAC:ct
:SCMOD:cat
:SFLNO:131
:ICOD:D
:QURY:START
	 | *  Dump records from ctcat131  
 	 if not get.cost.components(bcorig.ticpr, ctcat131.cpcp,"", o.err.mess) then  
 	 	 var.tffbs131.cpcp =  bcstc006.cost  
 	 else  
 	 	 var.tffbs131.cpcp =  empty.string(1;8)  
 	 endif  
 	 	  
 	 on case ctcat131.oprt  
 	 	 case tioprt.wages:  
 	 	 	 var.tffbs131.orty =  1 	 | *  tcorty.labor  
 	 	 	 break  
 	 	 case tioprt.machine:  
 	 	 	 var.tffbs131.orty =  2 	 | *  tcorty.machine  
 	 	 	 break  
 	 	 case tioprt.overhead:  
 	 	 	 if ctcat131.cmoh =  tccmoh.man.hrs then  
 	 	 	 	 var.tffbs131.orty =  3 	 | *  tcorty.oh.on.man  
 	 	 	 else  
 	 	 	 	 var.tffbs131.orty =  4 	 | *  tcorty.oh.on.mach  
 	 	 	 endif  
 	 	 	 break  
 	 endcase  
 	 if ctcat131.vafi =  tivafi.var then  
 	 	 var.tffbs131.vaco =  1 	 | *  tcyesno.yes  
 	 else  
 	 	 var.tffbs131.vaco =  2 	 | *  tcyesno.no  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:131
:SCPAC:ct
:SCMOD:cat
:SFLNO:131
:ICOD:S
:QURY:START
select 	 ctcat131.*
from ctcat131
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fbs
:TFLNO:131
:SCPAC:ct
:SCMOD:cat
:SFLNO:131
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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(   
 	   	  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   
 	  dump 3 |   *  Currency Difference Contra account is added.
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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 	 |  *  tibom010
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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   
 	     
 |# 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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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 tem   
 	  if tipcs110.ittp  =  tcitta.standard and tipcs110.item  <>  prev.item then   
 	   	  select  	  tiitm001.opol   
 	   	  from  	  tiitm001   
 	   	  where  	  tiitm001.item  =  :tipcs110.item   
 	   	  selectdo   
 	   	  endselect   
 	  endif   
 	     
 	  |   *  build item code   
 	  if tipcs110.ittp  =  tcitta.standard then   
 	   	  if (tiitm001.opol  =  tcopol.anonymous) then   
 	   	   	  var.tibom010.sitm  =  segment.item.code (tipcs110.item, "")    
 	   	  else   
 	   	   	  var.tibom010.sitm  =  get.part.item.code(tipcs110.cbdg, tipcs110.bccd,tipcs110.item)   
 	   	  endif   
 	  else   
 	   	  var.tibom010.sitm  =  get.part.item.code(tipcs110.cbdg, tipcs110.bccd,tipcs110.item)   
 	  endif   
 	     
 	  |   *  dump   
 	  dump 3   
 	  |   *  store current item code   
 	  prev.item  =  tipcs110.item
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:110
:ICOD:D
:QURY:START
	 | *  set variable /  fixed costs 	 	 	 | #  CNT.sn  
 	 if ticpr110.vafi =  tivafi.var then  
 	 	 var.ticpr110.vaco =  tcyesno.yes  
 	 else  
 	 	 var.ticpr110.vaco =  tcyesno.no  
 	 endif 	 	 	 	 	 	 | #  CNT.en  
 	  
 	 | *  currency, calc. method 	  
 	 if ticpr110.kocl =  tckocl.charge then  
 	 	 var.ticpr110.ccur =  hold.ccur  
 	 	 var.ticpr110.cmth =  ticpr110.cmth  
 	 else  
 	 	 var.ticpr110.ccur =  ""                                  
 	 	 var.ticpr110.cmth =  ltoe(0)  
 	 endif  
 	  
 	 fill.var.ticpr110.cpch("ticpr110") 	 	 | *  surcharge amount  
 	 fill.var.ticpr110.chpr("ticpr110") 	 	 | *  surcharge percentage  
 	 fill.var.ticpr110.chcp(ticpr110.chcp) 	 | *  cost components  
 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:110
:ICOD:S
:QURY:START
select 	 ticpr110.*  	 | *  Surcharges by Item Group
from 	 ticpr110
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:130
:ICOD:D
:QURY:START
	 | *  set variable /  fixed costs 	 	 | #  CNT.sn  
 	 if ticpr130.vafi =  tivafi.var then  
 	 	 var.ticpr110.vaco =  tcyesno.yes  
 	 else  
 	 	 var.ticpr110.vaco =  tcyesno.no  
 	 endif 	 	 	 	 	 | #  CNT.en  
 	  
 	 	  
 	 | *  currency and surcharge method  
 	 if ticpr130.kocl =  tckocl.charge then  
 	 	 var.ticpr110.ccur =  hold.ccur  
 	 	 var.ticpr110.cmth =  ticpr130.cmth  
 	 else  
 	 	 var.ticpr110.ccur =  ""                             
 	 	 var.ticpr110.cmth =  ltoe(0)  
 	 endif  
 	  
 	 var.ticpr110.item =  segment.item.code (ticpr130.item, "")                                                                                                          
 	 var.ticpr110.cwar (1;6) =  empty.string (1;6)  
 	 var.ticpr110.citg (1;6) =  empty.string (1;6)  
 	  
 	 fill.var.ticpr110.cpch("ticpr130") 	 	 | *  surcharge amount  
 	 fill.var.ticpr110.chpr("ticpr130") 	 	 | *  surcharge percentage  
 	 fill.var.ticpr110.chcp(ticpr130.chcp) 	 | *  cost components 	  
 	  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:130
:ICOD:S
:QURY:START
select 	 ticpr130.*  	 | *  Surcharges by Item
from 	 ticpr130
where 	 ticpr130.cntr =  ""                                           	                                          | *                                           no container item
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:110
:SCPAC:ti
:SCMOD:cpr
:SFLNO:130
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:cpr
:SFLNO:150
:ICOD:D
:QURY:START
	 	 	 	 	 	 | #  CNT.sn  
 	 | *  set vaco: variable or fixed costs  
 	 var.ticpr150.vaco =  variable.costs(ticpr150.vafi)  
 	 	  
 	 | *  set orty: Type of Opration Costs  
 	 var.ticpr150.orty =  set.orty(ticpr150.oprt, ticpr150.cmoh)  
 	 	 	 	 	 	 | #  CNT.en  
 	 | *  fill multi -  currency field  
 	 for element =  1 to 3  
 	 	 var.ticpr150.rate(element) =  fill.mc.field.double(  
 	 	 	 	 ticpr150.rate, | #  CNT.chng  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 ret.val =  get.cost.components(bcorig.ticpr,ticpr150.cpcp, "", err.mess)                                                                                            
 	  
 	 dump 1  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:cpr
:SFLNO:150
:ICOD:S
:QURY:START
select 	 ticpr150.*  	 | *  Operation Rates
from 	 ticpr150
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:130
:ICOD:D
:QURY:START
	 	 	 	 	 	 | #  CNT.sn  
 	 | *  set vaco: variable or fixed costs  
 	 var.ticpr150.vaco =  variable.costs(tipcs130.vafi)  
 	 	  
 	 | *  set orty: Type of Opration Costs  
 	 var.ticpr150.orty =  set.orty(tipcs130.oprt, tipcs130.cmoh)  
 	 	 	 	 	 	 | #  CNT.en  
 	 | *  get budget code  
 	 var.ticpr150.cprj =  get.budget.code(  
 	 	 	 	 	 tipcs130.cbdg,  
 	 	 	 	 	 tipcs130.bccd)  
 	  
 	 | *  fill multi currency field  
 	 for element =  1 to 3  
 	 	 var.ticpr150.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs130.rate,  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 ret.val =  get.cost.components(bcorig.ticpr,tipcs130.cpcp, "", err.mess)                                                            
 	 dump 7  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:130
:ICOD:S
:QURY:START
select 	 tipcs130.*  	 | *  Operation Rates by Budget
from 	 tipcs130
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:130
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:300
:ICOD:D
:QURY:START
	 	 	 	 	 	 	 | #  CNT.sn  
 	 | *  set vaco: variable or fixed costs  
 	 var.ticpr150.vaco =  variable.costs(tipcs300.vafi)  
 	 	  
 	 | *  set orty: Type of Opration Costs  
 	 var.ticpr150.orty =  set.orty(tipcs300.oprt, tipcs300.cmoh)  
 	 	 	 	 	 	 	 | #  CNT.sn  
 	 | *  fil multi currency field 	 	  
 	 for element =  1 to 3  
 	 	 var.ticpr150.rate(element) =  fill.mc.field.double(  
 	 	 	 	 tipcs300.rate, 	 | #  CNT.canged  
 	 	 	 	 element,  
 	 	 	 	 0.0) 	  
 	 endfor  
 	 ret.val =  get.cost.components(bcorig.ticpr,tipcs300.cpcp, "", err.mess)                                                                                            
 	 dump 4
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:300
:ICOD:S
:QURY:START
select 	 tipcs300.*  	 | *  Operates Rates by Project
from 	 tipcs300
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:cpr
:TFLNO:150
:SCPAC:ti
:SCMOD:pcs
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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  	  |# 210805.so   
 |  	   	  if tmp.kitm  =  tckitm.subcontracting then   
 |  	   	   	  continue   
 |  	   	  endif  	   	   	   	   	  |# 210805.eo   
 	     
 	   	  |   *  initialize for new item   
 	   	  if ticpr200.item  <>  var.item then   
 	   	   	  get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)   
 	   	  endif   
 	     
 	   	  |   *  fill Surcharges by item flag   
 	   	  fill.var.spit.for.ticpr201(   
 	   	   	   	  ticpr200.cpcc,   
 	   	   	   	  ticpr200.item)   
 	   	     
 	   	  |   *  initialize aggregates when new item or new calc code.   
 	   	  init.aggr.amnts.and.nuni()   
 	  endif   
 	     
 	  |   *  no cost prices for Subcontracting Items   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  var.cpcc  =  ticpr200.cpcc  	   	  |# 210805.n   
 	   	  prev.item  =  ticpr200.item  	   	  |# 210805.n   
 	   	  prev.kitm  =  tmp.kitm  	   	   	  |# 1391462.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, |# CNT.o   
 	   	  var.amnt(element)  =  fill.mc.field.double(ticpr200.famt, |# CNT.n   
 	   	   	   	   	   	   	  element,   
 	   	   	   	   	   	   	  0.0)   
 	  endfor  	   	   	   	   	   	  |# MCR.en  	     
 	     
 	  var.amnt.fixed  	    =  ticpr200.famt  -  ticpr200.mamt  	  |# CNT.n   
 	  var.amnt.var  	    =  ticpr200.mamt  	   	   	  |# CNT.n   
 	  var.nuni  =  ticpr200.nuni   
 	  get.cost.components(bcorig.ticpr, ticpr200.cpcp, "", tmp.errmess)    
 	  var.cpcp  =  bcstc006.cost   
 	  prev.item  =  ticpr200.item  	  |   *  in Baan IV format   
 	  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,  	   	  |# CNT.o   
 	   	   	   	   	   	   	  ticpr200.famt,  	   	  |# CNT.n   
 	   	   	   	   	   	   	  element,   
 	   	   	   	   	   	   	  0.0)   
 	   	  endfor  	   	   	   	   	   	  |# MCR.en   
 	   	     
 	   	  aggr.amount(  	  | ticpr200.amnt,  	  |# MCR.o   
 	   	   	   	  var.ticpr200.amnt,  	  |# MCR.n   
 	   	   	   	  var.amnt.var,  	   	  |# CNT.n   
 	   	   	   	  var.amnt.fixed,  	   	  |# CNT.n   
 	   	   	   	  ticpr200.nuni,   
 	   	   	   	  ticpr010.cref,   
 	   	   	   	  tmp.kitm)   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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.10.ticpr340.aggr.cpcp(   
 	   	   	   	   	  prev.kitm)  	   	  |# 1391462.n   
 |  	   	   	   	   	  tmp.kitm) |# 237409.n  	  |# 1391462.o   
 	   	   	  dump.7.ticpr306.aggr.cpcp()   
 	   	  endif   
 	     
 |  	   	  |   *  no cost prices for Subcontracting Items  	  |# 210805.so   
 |  	   	  if tmp.kitm  =  tckitm.subcontracting then   
 |  	   	   	  continue   
 |  	   	  endif  	   	   	   	   	  |# 210805.eo   
 	   	     
 	   	  |   *  initialize for new item   
 	   	  if ticpr300.item  <>  prev.item then   
 	   	   	  get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)   
 	   	  endif   
 	   	     
 	   	  |   *  fill Surcharges by item flag   
 	   	  fill.var.spit.for.ticpr301(   
 	   	   	   	  ticpr300.item,   
 	   	   	   	  ticpr300.indt)   
 	     
 	   	  |   *  intialize aggregates for new item  /  indt   
 	   	  init.aggr.amnts.and.nuni()   
 	  endif   
 	     
 	  |   *  no cost prices for Subcontracting Items   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  prev.item  =  ticpr300.item  	   	   	  |# 210805.n   
 	   	  var.indt  =  ticpr300.indt  	   	   	  |# 210805.n   
 	   	  prev.kitm  =  tmp.kitm  	   	   	  |# 1391462.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.amnt.fixed  	    =  ticpr300.famt  -  ticpr300.mamt  	  |# CNT.n   
 	  var.amnt.var  	    =  ticpr300.mamt  	   	  |# CNT.n   
 	     
 	  |   *  famt and mamt are sometimes both empty  	  |# CNT1.sn   
 	  if isspace(ticpr300.cpty) or  	   	   	   	     
 	   	  (ticpr300.famt  =  0.0 and ticpr300.mamt  =  0.0 and ticpr300.amnt  <>  0.00)   
 	  then   
 	   	  var.amnt.var  =  var.amnt(1)   
 	  endif  	   	   	   	   	   	  |# CNT1.en   
 	   	     
 	  var.nuni  =  ticpr300.nuni   
 	  get.cost.components(bcorig.ticpr, ticpr300.cpcp, "", tmp.errmess)    
 	  var.cpcp  =  bcstc006.cost   
 	  var.indt  =  ticpr300.indt   
 	  prev.item  =  ticpr300.item   
 	  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.10.ticpr340.eff.cpcp(   
 	   	   	   	  tmp.kitm) |# 237409.n   
 	   	  dump.7.ticpr306.eff.cpcp()   
 	  else   
 	   	  |   *  aggregate the amounts and unit on the 3 aggr. cost components   
 	   	  |   *  and add the cpcp to the Item's Cost Component Structure   
 	   	  for element  =  1 to 3  	   	   	  |# MCR.sn   
 	   	   	  var.ticpr300.amnt(element)  =  fill.mc.field.double(   
 	   	   	   	   	   	   	  ticpr300.amnt,   
 	   	   	   	   	   	   	   	  element,   
 	   	   	   	   	   	   	   	  0.0)   
 	   	  endfor  	   	   	   	   	  |# MCR.en   
 	   	  aggr.amount(  	  | ticpr300.amnt,  	  |# MCR.o   
 	   	   	   	  var.ticpr300.amnt,  	  |# MCR.n   
 	   	   	   	  var.amnt.var,  	   	  |# CNT.n   
 	   	   	   	  var.amnt.fixed,  	   	  |# CNT.n   
 	   	   	   	  ticpr300.nuni,   
 	   	   	   	  ticpr010.cref,   
 	   	   	   	  tmp.kitm)   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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  =  ""  	  |   *   no container items
order by ticpr300._index1  	  |   *  Sort by Item, indt
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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.9.ticpr240.aggr.cpcp(   
 	   	   	   	   	  tmp.kitm) |# 237409.n   
 	   	   	  dump.8.ticpr206.aggr.cpcp()   
 	   	  endif   
 	     
 	   	  |   *  initialize for new item   
 	   	  |   *  get item type and item group   
 	   	  get.calc.part.type.group(   
 	   	   	  tipcs150.cbdg,   
 	   	   	  tipcs150.ccpc,   
 	   	   	  tmp.kitm, tmp.citg, tmp.cpcp)   
 	     
 	   	  |   *  no cost prices for Subcontracting Items   
 	   	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	   	  continue   
 	   	  endif   
 	     
 	   	  |   *  initialized arrays  	     
 	   	  get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)   
 	   	  init.aggr.amnts.and.nuni()   
 	   	     
 	  endif   
 	     
 	  |   *  no cost prices for Subcontracting Items   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  continue   
 	  endif   
 	     
 	  |   *  fill values to be used in dump  	     
 	  var.cpcc  =  ticpr000.sccc |   *  Calc. code already in item code   
 	  var.item  =  tmp.item   
 |  	  var.amnt  =  tipcs150.amnt  	   	  |# MCR.o   
 	  for element  =  1 to 3  	   	   	  |# MCR.sn   
 	   	  var.amnt(element)  =  fill.mc.field.double(   
 |  	   	   	   	   	   	  tipcs150.amnt,  	  |# CNT.o   
 	   	   	   	   	   	  tipcs150.famt,  	  |# CNT.n   
 	   	   	   	   	   	  element,   
 	   	   	   	   	   	  0.0)   
 	  endfor  	   	   	   	   	  |# MCR.en   
 	  var.amnt.fixed  	    =  tipcs150.famt  -  tipcs150.mamt  	  |# CNT.n   
 	  var.amnt.var  	    =  tipcs150.mamt  	   	   	  |# CNT.n   
 	     
 	  var.nuni  =  tipcs150.nuni   
 	  get.cost.components(bcorig.ticpr, tipcs150.cpcp, "", tmp.errmess)    
 	  var.cpcp  =  bcstc006.cost   
 	     
 	     
 	  |   *  write details and aggregate   
 	  dump.3.ticpr205.det.cpcp()   
 	  if detailed.cpcp(tmp.kitm, tmp.citg, tipcs150.cpcp) then   
 	   	  dump.1.ticpr200.eff.cpcp()   
 	   	  dump.9.ticpr240.eff.cpcp(   
 	   	   	   	  tmp.kitm) |# 237409.n   
 	   	  dump.8.ticpr206.eff.cpcp()   
 	  else   
 	   	  |   *  aggregate the amounts and unit on the 3 aggr. cost components   
 	   	  for element  =  1 to 3  	   	  |# MCR.sn   
 	   	   	  var.tipcs150.amnt(element)  =  fill.mc.field.double(   
 |  	   	   	   	   	   	   	  tipcs150.amnt,  	  |# CNT.o   
 	   	   	   	   	   	   	  tipcs150.famt,  	   	  |# CNT.n   
 	   	   	   	   	   	   	  element,   
 	   	   	   	   	   	   	  0.0)   
 	   	  endfor  	   	   	   	  |# MCR.en   
 	   	  var.amnt.fixed  	    =  tipcs150.famt  -  tipcs150.mamt  	  |# CNT.n   
 	   	  var.amnt.var  	    =  tipcs150.mamt  	   	   	  |# CNT.n   
 	   	  aggr.amount( | tipcs150.amnt,  	  |# MCR.o   
 	   	   	  var.tipcs150.amnt, |# MCR.n   
 	   	   	  var.amnt.var,  	   	  |# CNT.n   
 	   	   	  var.amnt.fixed,  	   	  |# CNT.n   
 	   	   	  tipcs150.nuni,   
 	   	   	  ticpr010.cref,   
 	   	   	  tmp.kitm)   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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.9.ticpr240.aggr.cpcp(   
 	   	   	  tmp.kitm) |# 237409.n   
 	  dump.8.ticpr206.aggr.cpcp()
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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   
 	   	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	   	  continue   
 	   	  endif   
 	   	     
 	   	  get.aggr.cpcp(tmp.kitm, tmp.citg, tmp.cpcp)   
 	   	  init.aggr.amnts.and.nuni()   
 	   	     
 	  endif   
 	     
 	  |   *  no cost prices for Subcontracting Items   
 	  if tmp.kitm  =  tckitm.subcontracting then   
 	   	  continue   
 	   	  prev.kitm  =  tmp.kitm  	   	   	  |# 1391462.n   
 	  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.amnt.fixed  	    =  tipcs350.fame  -  tipcs350.mame  	  |# CNT.n   
 	  var.amnt.var  	    =  tipcs350.mame  	   	   	  |# CNT.n   
 	     
 	  |   *  fame and mame are sometimes both empty  	  |# CNT1.sn   
 	  if isspace(tipcs350.cpty) or  	   	   	   	     
 	   	  (tipcs350.fame  =  0.0 and tipcs350.mame  =  0.0 and tipcs350.amte  <>  0.00)   
 	  then   
 	   	  var.amnt.var  =  var.amnt(1)   
 	  endif  	   	   	   	   	   	  |# CNT1.en   
 	   	     
 	     
 	  var.nuni  =  tipcs350.nune   
 	  get.cost.components(bcorig.ticpr, tipcs350.cpcp, "", tmp.errmess)    
 	  var.cpcp  =  bcstc006.cost   
 	     
 	  |   *  dump details and aggrate   
 	  dump.3.ticpr205.det.cpcp()   
 	  dump.6.ticpr305.det.cpcp()   
 	  if detailed.cpcp(tmp.kitm, tmp.citg, tipcs350.cpcp) then   
 	   	  dump.1.ticpr200.eff.cpcp()  	   	     
 	   	  dump.8.ticpr206.eff.cpcp()   
 	   	  dump.9.ticpr240.eff.cpcp(   
 	   	   	   	  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   
 	   	  var.amnt.fixed  	    =  tipcs350.fame  -  tipcs350.mame  	  |# CNT.n   
 	   	  var.amnt.var  	    =  tipcs350.mame  	   	   	  |# CNT.n   
 	   	  aggr.amount(  	  | tipcs350.amte,  	  |# MCR.o   
 	   	   	   	  var.tipcs350.amte,  	  |# MCR.n   
 	   	   	   	  var.amnt.var,  	   	  |# CNT.n   
 	   	   	   	  var.amnt.fixed,  	   	  |# CNT.n   
 	   	   	   	  tipcs350.nune,   
 	   	   	   	  ticpr010.cref,   
 	   	   	   	  tmp.kitm)   
 	  endif   
 	     
 	  |   *  save project   
 	  prev.cprj  =  tipcs350.cprj
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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
order by tipcs350._index1 |   *  cprj, item, cpcp  =  new item code, cpcp
:QURY:END
:TEXT:

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

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

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

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:140
:ICOD:S
:QURY:START
select 	 tipcs140.*
from 	 tipcs140
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:140
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:320
:SCPAC:ti
:SCMOD:pcs
:SFLNO:320
:ICOD:S
:QURY:START
select 	 tipcs320.*
from 	 tipcs320
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:D
:QURY:START
	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs150.cpcp,  
 	 	 	 	 	 "",                                                                
 	 	 	 	 	 error.message)  
 	  
 	 | *  Construct new project code and new item code.  
 	 var.tipcs350.cprj =  get.budget.code(tipcs150.cbdg,  
 	 	 	 	 	 tipcs150.bccd)  
 	 var.tipcs350.item =  segment.item.code(tipcs150.ccpc,  
 	 	 	 	 	 var.tipcs350.cprj)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:S
:QURY:START
select 	 tipcs150.*
from 	 tipcs150
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:150
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:D
:QURY:START
	 return.value =  get.cost.components(  
 	 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 	 tipcs350.cpcp,  
 	 	 	 	 	 "",                                                                
 	 	 	 	 	 error.message)  
 	 | *  Construct new project code and new item code.  
 	 var.tipcs350.cprj =  get.ti.project(tipcs350.cprj)  
 	 var.tipcs350.item =  segment.item.code(tipcs350.item, var.tipcs350.cprj)  
 	 | *  fame and mame are sometimes both empty 	 | #  CNT1.sn  
 	 if isspace(tipcs350.cpty) or 	 	 	 	  
 	 	 (tipcs350.fame =  0.0 and tipcs350.mame =  0.0 and tipcs350.amte <>  0.00)  
 	 then  
 	 	 tipcs350.fame =  tipcs350.amte  
 	 	 tipcs350.mame =  tipcs350.amte  
 	 endif 	 	 	 	 	 	 | #  CNT1.en  
 	  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:350
:SCPAC:ti
:SCMOD:pcs
:SFLNO:350
:ICOD:S
:QURY:START
select tipcs350.*
from tipcs350
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:160
:ICOD:D
:QURY:START
	 return.value =  get.cost.components(  
 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 tipcs160.cpcp,  
 	 	 	 	 "",                                        
 	 	 	 	 error.message)  
 	 | *  Construct new project code.  
 	 var.tipcs360.cprj =  get.budget.code(tipcs160.cbdg,  
 	 	 	 	 tipcs160.bccd)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:160
:ICOD:S
:QURY:START
select 	 tipcs160.*
from 	 tipcs160
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:160
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:D
:QURY:START
	 return.value =  get.cost.components(  
 	 	 	 	 bcorig.ticpr,  
 	 	 	 	 tipcs360.cpcp,  
 	 	 	 	 "",                                  
 	 	 	 	 error.message)  
 	 | *  Construct new project code.  
 	 var.tipcs360.cprj =  get.ti.project(tipcs360.cprj)  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
:RELE:61
:CUST:f106
:TCPAC:ti
:TCMOD:pcs
:TFLNO:360
:SCPAC:ti
:SCMOD:pcs
:SFLNO:360
:ICOD:S
:QURY:START
select 	 tipcs360.*
from 	 tipcs360
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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  	   	   	   	  |# TELAIR.n   
 	  hold.tdinv700.sern  =  tdinv700.sern  	   	   	   	  |# TELAIR.n   
 |  	  var.whinr110.trdt  =  utc(tdinv700.trdt, tdinv700.trtm)  	  |# 800  -  142000.o   
 |  	  var.whinr110.seqn  =  tdinv700.sern  +  1  	   	   	  |# 800  -  142000.o   
 	  var.whinr110.trdt  =  utc(tdinv700.trdt, 0)  	   	   	  |# 800  -  142000.sn   
 	  if check1.trdt  <>  tdinv700.trdt then   
 	   	  check1.trdt  =  tdinv700.trdt   
 	   	  var.whinr110.seqn  =  1   
 	  else   
 	   	  var.whinr110.seqn  =  var.whinr110.seqn  +  1   
 	  endif   
 	   	   	   	   	   	   	   	   	  |# 800  -  142000.en   
 	  if hold.item  <>  tdinv700.item or   
 	  hold.cwar  <>  tdinv700.cwar then   
 	   	  var.whinr110.seqn  =  1  	   	   	   	   	  |# 800  -  142000.n   
 	   	  var.whinr110.qhnd  =  0.0  	   	   	  |# 800  -  142486.n   
 	   	  if hold.negative  >  0 then   
 	   	   	  var.whwmd255.coqu  =  hold.negative   
 	   	   	  dump 13   
 	   	   	  hold.negative  =  0.0   
 	   	  endif   
 	   	  if tdinv700.item  <>  hold.item then   
 	   	   	  select tiitm001.stva, tiitm001.ltcp,   
 	   	   	  	 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(  	  "",  	  |*   project  	  |# fp3.sn    
 	   	   	   	   	   	  tdinv700.item) then  	  |# fp3.en   
 	   	   	   	  var.whinr110.valm  =  5  	  |*  lot   
 	   	   	   	   	   	   	   	  |# 800  -  145084.sn   
 	   	   	   	  determine.lot.inventory.onhand(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  tdinv700.cwar,   
 	   	   	   	   	   	   	  nr.lots,   
 	   	   	   	   	   	   	  arr.lots)   
 	   	   	   	   	   	   	   	  |# 800  -  145084.en   
 	   	   	  else  	   	   	   	   	   	  |# fp3.sn   
 	   	   	   	  var.whinr110.valm  =  6  	  |*  serial   
 	   	   	   	  determine.lot.inventory.onhand(   
 	   	   	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	   	   	  tdinv700.cwar,   
 	   	   	   	   	   	   	  nr.lots,   
 	   	   	   	   	   	   	  arr.lots)   
 	   	   	  endif  	   	   	   	   	   	  |# fp3.en   
 	   	  endif   
 	   	  hold.item  =  tdinv700.item   
 	   	  hold.cwar  =  tdinv700.cwar   
 	   	  select tdinv001.stoc, tdinv001.hstb, tdinv001.hstd   
 	   	  from  	  tdinv001   
 	   	  where  	  tdinv001._index1  =  {:hold.cwar, :hold.item}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  selectempty   
 	   	   	  tdinv001.stoc  =  0.0   
 	   	   	  tdinv001.hstb  =  0.0   
 	   	   	  tdinv001.hstd  =  0   
 	   	  endselect   
 	   	  var.whina112.qskt  =  0.0   
 	   	  to.be.received  =  0.0   
 	   	  issued  =  0.0   
 |  	   	  i  =  0  	   	   	   	   	  |# 218323.o   
 	   	  i  =  1  	   	   	   	   	   	  |# 218323.n   
 	   	  dummy.receipt.qty  =  0.0   
 	   	  dummy.array.nr  =  0   
 	   	  receipt.counter  =  0   
 	   	  set.mem(arr.whina112.trdt, "")    
 	   	  set.mem(arr.whina112.seqn, 0)   
 	   	  set.mem(arr.whina112.qskt, 0.0)   
 	   	  select tdinv700._index1,   
 	   	   	  tdinv700.quan:curr.quan,   
 	   	   	  tdinv700.koor:curr.koor,  	   	   	   	   	   	  |# 205835.n   
 	   	   	  tdinv700.kost:curr.kost   
 	   	  from  	  tdinv700, tcmcs003   
 	   	  where  	  tdinv700._index1  =  {:hold.item, "", :hold.cwar}    
 	   	  and  	  tdinv700.trdt  >=  :tdinv001.hstd   
 	   	  and  	  tcmcs003._index1  =  {tdinv700.cwar}   
 	   	  and  	  tcmcs003.typw  <>  tctypw.transito   
 	   	  and  	  tdinv700.cntr  =  ""    
 	   	  order by tdinv700._index1   
 	   	  selectdo   
 	   	   	   	   	   	   	   	   	   	   	  |# 800  -  142000.sn   
 	   	   	  if check2.item  <>  tdinv700.item or   
 	   	   	  check2.cwar  <>  tdinv700.cwar or   
 	   	   	  check2.trdt  <>  tdinv700.trdt then   
 	   	   	   	  check2.item  =  tdinv700.item   
 	   	   	   	  check2.cwar  =  tdinv700.cwar   
 	   	   	   	  check2.trdt  =  tdinv700.trdt   
 	   	   	   	  check.seqn  =  1   
 	   	   	  else   
 	   	   	   	  check.seqn  =  check.seqn  +  1   
 	   	   	  endif   
 	   	   	   	   	   	   	   	   	   	   	  |# 800  -  142000.en   
 	   	   	  if (curr.kost  =  tckost.stc.correction and curr.quan  >  0) or   
 	   	   	  ((curr.kost  =  tckost.pur.receipt or   
 	   	   	  curr.kost  =  tckost.prd.receipt or   
 	   	   	  curr.kost  =  tckost.rpl.receipt) and curr.quan  >  0) or   
 	   	   	  ((curr.kost  =  tckost.sls.delivery or   
 	   	   	  curr.kost  =  tckost.prd.mat.issue or   
 	   	   	  curr.kost  =  tckost.rpl.delivery) and curr.quan  <  0) or   
 |  	   	   	  (curr.kost  =  tckost.stc.transfer and curr.quan  >  0) then  	   	  |# 205835.o   
 	   	   	   	   	   	   	   	   	   	   	   	  |# 217134  -  1.so   
 |  	   	   	  (curr.kost  =  tckost.stc.transfer and curr.quan  >  0 and  	   	   	  |# 205835.n   
 |  	   	   	  curr.koor  <>  tckoor.act.sls and curr.koor  <>  tckoor.sma.order) then  	  |# 205835.n   
 	   	   	   	   	   	   	   	   	   	   	   	  |# 217134  -  1.eo   
 	   	   	   	   	   	   	   	   	   	   	   	  |# 217134  -  1.sn   
 	   	   	  (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  	     
 	   	   	   	   	   	   	   	   	   	   	   	  |# 217134  -  1.en   
 	   	   	   	  to.be.received  =  to.be.received  +  abs(curr.quan)   
 	   	   	   	  i  =  i  +  1   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  |# array.len  =  array.len  +  100 |# 228714.o   
 	   	   	   	   	  array.len  =  array.len  +  200 |# 228714.n   
 	   	   	   	   	  alloc.mem(arr.whina112.trdt, 22, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.seqn, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.qskt, array.len)   
 	   	   	   	  endif   
 |  	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tdinv700.trdt, tdinv700.trtm)  	  |# 800  -  142000.o   
 	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tdinv700.trdt, 0)  	   	   	  |# 800  -  142000.n   
 |  	   	   	   	  arr.whina112.seqn(i)  =  tdinv700.sern  +  1  	   	   	  |# 800  -  142000.o   
 	   	   	   	  arr.whina112.seqn(i)  =  check.seqn  	   	   	   	  |# 800  -  142000.n   
 	   	   	   	  arr.whina112.qskt(i)  =  abs(curr.quan)   
 	   	   	  else   
 	   	   	   	  issued  =  issued  +  abs(curr.quan)   
 	   	   	  endif   
 	   	  selecteos   
 |  	   	   	  onhand.inventory  =  max(tdinv001.hstb  +  to.be.received  -  issued,  	  |# 217134.o   
 |  	   	   	   	   	   	   	  tdinv001.stoc)  	   	   	  |# 217134.o   
 	   	   	  onhand.inventory  =  tdinv001.stoc  	   	   	   	   	  |# 217134.n   
 	   	   	  if onhand.inventory  >  to.be.received  -  issued then   
 	   	   	   	  |*  create dummy receipt   
 	   	   	   	  dummy.receipt.qty  =  onhand.inventory  -     
 	   	   	   	   	   	   	   	  to.be.received  +  issued   
 	   	   	   	  to.be.received  =  to.be.received  +  dummy.receipt.qty   
 |  	   	   	   	  i  =  i  +  1  	   	   	  |# 218323.o   
 	   	   	   	  i  =  1  	   	   	   	  |# 218323.n   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  |# array.len  =  array.len  +  100 |# 228714.o   
 	   	   	   	   	  array.len  =  array.len  +  200  	  |# 228714.n   
 	   	   	   	   	  alloc.mem(arr.whina112.trdt, 22, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.seqn, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.qskt, array.len)   
 	   	   	   	  endif   
 |  	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tdinv700.trdt, tdinv700.trtm)  	  |# 800  -  142000.o   
 	   	   	   	   	   	   	   	  |# 218323.so   
 |  	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tdinv700.trdt, 0)  	   	   	  |# 800  -  142000.n   
 |  	   	   	   	  arr.whina112.seqn(i)  =  999  	  |*  take care   
 	   	   	   	   	   	   	   	  |# 218323.eo   
 	   	   	   	   	   	   	   	  |# 218323.sn   
 	   	   	   	  arr.whina112.trdt(1,i)  =  utc( date.to.num(1980,1,1), 0)   
 	   	   	   	  arr.whina112.seqn(i)  =  1   
 	   	   	   	   	   	   	   	  |# 218323.en   
 	   	   	   	  arr.whina112.qskt(i)  =  dummy.receipt.qty   
 	   	   	   	  dummy.array.nr  =  i   
 	   	   	   	   	   	   	   	  |# 218323.sn   
 	   	   	   	  create.tdinv700.correction.record()   
 	   	   	  else   
 	   	   	   	  i  =  2  	   	   	   	  |# 218323.en   
 	   	   	  endif   
 	   	  endselect   
 |  	   	  i  =  1  	   	   	   	   	  |# 218323.o   
 	   	  prev.sern  =  0   
 	  endif   
 	  if hold.tdinv700.trdt  <  tdinv001.hstd then   
 	   	  continue   
 	  endif   
 	  var.whinr110.qstk  =  tdinv700.quan   
 	  var.whinr110.bpid  =  empty()   
 	  var.whinr110.pono  =  tdinv700.pono   
 	  var.whinr110.srnb  =  0   
 	  var.whinr110.shpm  =  " "  	   	   	   	   	   	  |# 202924.n   
 	  var.whinr110.shpo  =  0  	   	   	   	   	   	   	  |# 202924.n   
 	  var.whinr110.rcno  =  ""  	   	   	   	   	   	   	  |# 227896.sn    
 	  var.whinr110.rcln  =  0  	   	   	   	   	   	   	  |# 227896.en   
 	  on case tdinv700.koor   
 	  case tckoor.act.pur:   
 	   	  if not get.business.partner(tdinv700.rlcd, bcstc.orgn.suno, o.mess) then   
 	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	  endif   
 	   	  get.purchase.order.line.data(  	   	   	  |# 213329.sn   
 	   	   	   	  true,  	   	  | inv   
 	   	   	   	  tdinv700.orno,   
 	   	   	   	  tdinv700.pono,   
 	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	  hold.tdinv700.trtm,   
 	   	   	   	  hold.tdinv700.sern,   
 	   	   	   	  "",  	  |*   Project    
 	   	   	   	  tdinv700.item,   
 	   	   	   	  tdinv700.quan,   
 	   	   	   	  var.whinr110.rcno,  	   	  |# 227896.sn   
 	   	   	   	  var.whinr110.rcln,  	   	  |# 227896.en   
 	   	   	   	  var.whinr110.srnb,   
 	   	   	   	  bom.line)  	   	   	  |# 213329.en   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	  if tdinv700.quan  <  0 then   
 |  	   	   	  get.return.purchase.order.line.data(  	  |# 213329.so   
 |  	   	   	   	   	  true,  	   	  | inv   
 |  	   	   	   	   	  tdinv700.orno,   
 |  	   	   	   	   	  tdinv700.pono,   
 |  	   	   	   	   	  hold.tdinv700.trdt,   
 |  	   	   	   	   	  hold.tdinv700.trtm,   
 |  	   	   	   	   	  hold.tdinv700.sern,   
 |  	   	   	   	   	  "",  	  |*   Project    
 |  	   	   	   	   	  tdinv700.item,   
 |  	   	   	   	   	  tdinv700.quan,   
 |  	   	   	   	   	  var.whinr110.srnb,   
 |  	   	   	   	   	  bom.line)  	   	  |# 213329.eo   
 	   	   	  errmess  =  ""    
 	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  break   
 	  case tckoor.act.sls:   
 	   	  if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.so   
 |  	   	  var.whinr110.srnb  =  determine.sales.order.sequence(  	  true,  	   	  | inv  	  |# 800  -  143063.n   
 |  	   	   	   	   	   	   	   	   	  tdinv700.orno,   
 |  	   	   	   	   	   	   	   	   	  tdinv700.pono,   
 |  	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.so   
 | |  	   	   	   	   	   	   	   	   	  tdinv700.trdt,   
 | |  	   	   	   	   	   	   	   	   	  tdinv700.trtm,  	   	  |# 800  -  143063.n   
 | |  	   	   	   	   	   	   	   	   	  tdinv700.sern,  	   	  |# 800  -  143063.n   
 |  	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.eo   
 |  	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.sn   
 |  	   	   	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 |  	   	   	   	   	   	   	   	   	  hold.tdinv700.trtm,   
 |  	   	   	   	   	   	   	   	   	  hold.tdinv700.sern,   
 |  	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.en   
 |  	   	   	   	   	   	   	   	   	  "",  	   	   	  |# 800  -   143063.n    
 |  	   	   	   	   	   	   	   	   	  tdinv700.quan)  	  |# 800  -  143063.n   
 	   	   	   	   	   	   	   	  |# SL204550.eo  	   	   	   	   	   	   	   	   	  |# 202924.sn   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	  get.sales.order.line.data(   
 	   	   	   	   	  true,  	   	  | inv   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	  hold.tdinv700.trtm,   
 	   	   	   	   	  hold.tdinv700.sern,   
 	   	   	   	   	  "",  	  |*   Project    
 	   	   	   	   	  tdinv700.item,   
 	   	   	   	   	  tdinv700.quan,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	  bom.line)   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  |*  shipment  /  line number are needed for COGS determination   
 	   	  |*  filling is conform include ibcswh0007   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	   	  errmess  =  ""    
 	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  else   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	  |*  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.   
 	   	   	   	  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  	   	   	   	  |# 243681.en   
 	   	   	   	   	  var.whinr110.shpm  =     
 	   	   	   	   	   	  edit$(tdinv700.orno, "999999")  &      
 	  edit$(tdinv700.pono, "999")    
 	   	   	   	   	  var.whinr110.shpo  =  var.whinr110.srnb   
 	   	   	   	   	  if var.whinr110.shpo  =  0 then   
 	   	   	   	   	   	  var.whinr110.shpo  =  10   
 	   	   	   	   	  endif   
 	   	   	   	  endif  	   	   	   	  |# 243681.n   
 	   	   	  endif  	   	   	   	   	  |# SL204550.en   
 	   	  endif   
 	   	  break   
 	  case tckoor.sma.order :   
 	   	  if not get.business.partner(tdinv700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  0,  	   	   	  |*  sequence   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  0,  	   	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  break   
 	  case tckoor.act.sfc:  	   	   	   	   	  |# 208542.sn   
 	   	  if tdinv700.kost  =  tckost.stc.transfer then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  endif   
 	   	  break  	   	   	   	   	   	  |# 208542.en   
 	  case tckoor.wrh.order :   
 	   	  if tdinv700.kost  <>  tckost.stc.correction then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  else   
 	   	   	  var.whinr110.pono  =  determine.new.pono(tdinv700.orno)   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 |  	   	  if tdinv700.quan  >  0 then  	   	   	  |# 226808.o   
 	   	  if tdinv700.kost  <>  tckost.stc.correction and  	  |# 226808.sn   
 	   	  tdinv700.quan  >  0 then  	   	   	  |# 226808.en   
 	   	   	  errmess  =  ""    
 	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  1,  	   	   	  |*  sequence   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  0,  	   	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  break   
 	  case tckoor.act.rpl :   
 	   	  if tdinv700.kost  =  tckost.stc.transfer then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	   	  |# 800  -  142206.sn   
 	   	  var.whinr110.srnb  =  determine.rpl.order.sequence(  	  tdinv700.orno,   
 	   	   	   	   	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	   	   	   	   	  tdinv700.kost,   
 	   	   	   	   	   	   	   	   	  tdinv700.cwar,   
 |  	   	   	   	   	   	   	   	   	  tdinv700.trdt)  	  |# TELAIR.o   
 	   	   	   	   	   	   	   	   	  hold.tdinv700.trdt)  	  |# TELAIR.n   
 	   	   	   	   	   	   	   	   	  |# 800  -  142206.en   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  1,  	   	   	  |*  sequence   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  0,  	   	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  break   
 	  case tckoor.pcs.wrh :   
 	   	  if tdinv700.kost  =  tckost.stc.transfer then   
 	   	   	  if (tdinv700.quan  <  0) then   
 	   	   	   	  var.whinr110.qstk  =  abs (tdinv700.quan)   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# 200  -  101937.sn   
 	   	  var.whinr110.pono  =  10   
 	   	  var.whinr110.srnb  =  1   
 	   	   	   	   	   	   	   	  |# 200  -  101937.en   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	  if tdinv700.quan  >  0 then   
 	   	   	  errmess  =  ""    
 	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tdinv700.koor,   
 	   	   	   	   	  tdinv700.orno,   
 	   	   	   	   	  tdinv700.pono,   
 	   	   	   	   	  0,  	   	   	  |*  sequence   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  0,  	   	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	  if isspace(errmess) then   
 	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	  endif   
 	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  break   
 	  endcase   
 	  if tdinv700.prst  <>  empty then   
 	   	  var.whinr110.prnt  =  tdinv700.prst   
 	  else   
 	   	  var.whinr110.prnt  =  tcyesno.no   
 	  endif   
 	  var.whinr110.koor  =  convert.tckoor(tdinv700.koor, tdinv700.orno)   
 	  if var.whinr110.koor  =  51 then | cycle count   
 	   	  var.whinr110.orno  =  get.new.cycle.count.order.number(   
 	   	   	   	   	   	  tdinv700.orno, tdinv700.cwar)   
 	  else   
 	   	  var.whinr110.orno  =  convert.number(   
 	   	   	   	   	  convert.tckoor.to.bcckon(tdinv700.koor), tdinv700.orno)   
 	  endif   
 	  if (tdinv700.koor  =  tckoor.act.sls or tdinv700.koor  =  tckoor.sma.order) and  	  |# 205835.n   
 	  tdinv700.kost  =  tckost.stc.transfer and tdinv700.quan  >  0 then  	   	  |# 205835.n   
 	   	  var.whinr110.kost  =  5  	   	  | tckost.issue  	   	   	   	  |# 205835.n   
 	  else   
 	   	   	   	   	   	   	   	   	   	   	  |# RN.sn   
 	   	  if tdinv700.koor  =  tckoor.act.sfc and   
 	   	  tdinv700.kost  =  tckost.stc.transfer and   
 	   	  tdinv700.pono  <>  0 then  	  | material   
 	   	   	  var.whinr110.kost  =  5  	   	  | issue   
 	   	   	  if tdinv700.quan  >  0 then   
 	   	   	   	  var.whinr110.qstk  =    -  tdinv700.quan  	  | negative issue   
 	   	   	  else   
 	   	   	   	  var.whinr110.qstk  =  abs(tdinv700.quan)   
 	   	   	  endif   
 	   	  else  	   	   	   	   	   	   	   	   	  |# RN.en   
 	   	   	  var.whinr110.kost  =  convert.tckost(tdinv700.kost, tdinv700.quan)   
 | 	   	   	  	  	  	  	  	  	  	 |#1992163.so   
 | 	   	   	  if var.whinr110.kost  =  3 and  	  |*  receipt  	   	   	  |# 231887.sn   
 | 	   	   	  tdinv700.koor  =  tckoor.wrh.order and   
 | 	   	   	  var.whinr110.qstk  >  0 and   
 | 	   	   	  tdinv700.quan  <  0 then   
 | 	   	   	   	  var.whinr110.qstk  =  tdinv700.quan  	     
 | 	   	   	  endif  	   	   	   	   	   	   	   	  |# 231887.en   
 | 	   	  	  	  	  	  	  	  	  	 |#1992163.eo   
 	   	  	  	  	  	  	  	  	  	 |#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   
 	  	  	  	  	  	  	  	  	  	    
 	   	   	  if var.whinr110.kost  =  3 and  	   	   	 |*  receipt   
 	   	   	  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  	   	   	   	   	   	   	     
 	   	   	  	  	  	  	  	  	  	    
 	  	  	  |*  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  	   	   	   	   	   	   	   	   	  |# RN.n   
 	  endif  	   	   	   	   	   	   	   	   	   	  |# 205835.n   
 	  itid  =  itid  +  1   
 	  var.whinr110.itid  =  edit$(itid,"999999999")   
 	  var.whinr110.itse  =  1   
 	   	   	   	   	   	  |# 800  -  142486.sn   
 	  |*  calculate quantity after transaction because it is not reliable in Baan4   
 	  if var.whinr110.kost  =  1 or  	   	  | tckost.stc.correction   
 	  var.whinr110.kost  =  3 then  	   	  | tckost.receipt   
 	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  +  var.whinr110.qstk   
 	  endif   
 	  if var.whinr110.kost  =  5 then  	   	  | tckost.issue   
 	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  -  var.whinr110.qstk   
 	  endif   
 	   	   	   	   	   	  |# 800  -  142486.en   
 | 	  if var.whinr110.valm  =  5 then  	  |# TELAIR.sn 	 |#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  	  |# fp3.sn  	 |#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  	   	   	   	   	   	  |# fp3.en   
 |  	  dump 1  	   	   	   	   	   	   	   	  |# 800  -  145084.o   
 	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.so   
 |  	  if receipt.counter  =  dummy.array.nr  -  1 then   
 |  	   	  receipt.counter  =  receipt.counter  +  1   
 |  	   	  hold.koor  =  var.whinr110.koor   
 |  	   	  hold.kost  =  var.whinr110.kost   
 |  	   	  hold.orno  =  var.whinr110.orno   
 |  	   	  hold.trdt  =  var.whinr110.trdt   
 |  	   	  hold.seqn  =  var.whinr110.seqn   
 |  	   	  hold.qstk  =  var.whinr110.qstk   
 |  	   	  hold.bpid  =  var.whinr110.bpid   
 |  	   	  itid  =  itid  +  1   
 |  	   	  var.whinr110.itid  =  edit$(itid,"999999999")   
 |  	   	  var.whinr110.itse  =  1   
 |  	   	  var.whinr110.koor  =  52  	  |*  adjustment order   
 |  	   	  var.whinr110.kost  =  1  	  |*  stock correction   
 |  	   	  var.whinr110.orno  =  "MIGRATION"    
 |  	   	  var.whinr110.trdt  =  arr.whina112.trdt(1,dummy.array.nr)   
 |  	   	  var.whinr110.seqn  =  999  	  |*  take care   
 |  	   	  var.whinr110.qstk  =  dummy.receipt.qty   
 |  	   	  var.whinr110.bpid  =  empty()   
 |  	   	   	   	   	   	  |# 800  -  142486.sn   
 |  	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  +  var.whinr110.qstk   
 |  	   	   	   	   	   	  |# 800  -  142486.en   
 |  	   	  dump 1   
 |  	   	  to.be.received  =  to.be.received  -  dummy.receipt.qty   
 |  	   	  if to.be.received  >=  onhand.inventory then   
 |  	   	   	  |*  totally consumed   
 |  	   	   	  var.whina112.qskt  =  0.0   
 |  	   	  else   
 |  	   	   	  if var.whina112.qskt  >  0 then   
 |  	   	   	   	  |*  not consumed   
 |  	   	   	   	  var.whina112.qskt  =  dummy.receipt.qty   
 |  	   	   	  else   
 |  	   	   	   	  |*  partially consumed   
 |  	   	   	   	  var.whina112.qskt  =  onhand.inventory  -  to.be.received   
 |  	   	   	  endif   
 |  	   	  endif   
 |  	   	  var.whina112.qstk  =  dummy.receipt.qty   
 |  	   	  dump 3   
 |  	   	  if isspace(var.whinr110.clot) then  	   	   	   	   	  |# TELAIR.n   
 |  	   	   	  get.standard.cost.price(tdinv700.item, dummy.receipt.qty,   
 |  	  |  	   	   	   	   	  tdinv700.trdt, true, false)  	   	  |# TELAIR.o   
 |  	   	   	   	   	   	  hold.tdinv700.trdt, true, false)  	  |# TELAIR.sn   
 |  	   	  else   
 |  	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot, dummy.receipt.qty,   
 |  	   	   	   	   	   	  hold.tdinv700.trdt, true, false)   
 |  	   	  endif  	   	   	   	   	   	   	   	   	  |# TELAIR.en   
 |  	   	  var.whinr110.koor  =  hold.koor   
 |  	   	  var.whinr110.kost  =  hold.kost   
 |  	   	  var.whinr110.orno  =  hold.orno   
 |  	   	  var.whinr110.trdt  =  hold.trdt   
 |  	   	  var.whinr110.seqn  =  hold.seqn   
 |  	   	  var.whinr110.qstk  =  hold.qstk   
 |  	   	  var.whinr110.bpid  =  hold.bpid   
 |  	  endif   
 	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.eo   
 	  if (tdinv700.kost  =  tckost.stc.correction and tdinv700.quan  >  0) or   
 	  ((tdinv700.kost  =  tckost.pur.receipt or   
 	  tdinv700.kost  =  tckost.prd.receipt or   
 	  tdinv700.kost  =  tckost.rpl.receipt) and tdinv700.quan  >  0) or   
 	  ((tdinv700.kost  =  tckost.sls.delivery or   
 	  tdinv700.kost  =  tckost.prd.mat.issue or   
 	  tdinv700.kost  =  tckost.rpl.delivery) and tdinv700.quan  <  0) or   
 |  	  (tdinv700.kost  =  tckost.stc.transfer and tdinv700.quan  >  0) then  	   	  |# 205835.o   
 	  (tdinv700.kost  =  tckost.stc.transfer and tdinv700.quan  >  0 and  	   	  |# 205835.n   
 	  tdinv700.koor  <>  tckoor.act.sls and tdinv700.koor  <>  tckoor.sma.order) then  	  |# 205835.n   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.so   
 |  	   	  if var.whinr110.valm  =  5 then  	   	   	   	   	  |# 800  -  145084.sn   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.eo   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.sn   
 	   	  if var.whinr110.valm  =  5 or var.whinr110.valm  =  6 then   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.en   
 	   	   	  var.whina112.qstk  =  abs(tdinv700.quan)   
 	   	   	  receipt.counter  =  receipt.counter  +  1   
 	   	   	  to.be.received  =  to.be.received  -  abs(tdinv700.quan)   
 	   	   	  if to.be.received  >=  onhand.inventory then   
 	   	   	   	  |*  totally consumed   
 	   	   	   	  dump 1   
 	   	   	   	  var.whina112.qskt  =  0.0   
 	   	   	   	  dump 3   
 |  	   	   	   	  if isspace(var.whinr110.clot) then  	   	   	  |# fp3.o   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.sn   
 	   	   	   	  if isspace(var.whinr110.clot) and isspace(var.whinr110.serl) then   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.en   
 	  	  	  	  	 |*  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   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.sn   
 	   	   	   	   	  if not isspace(var.whinr110.serl) then   
 	   	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 	   	   	   	   	  else   
 	   	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 	   	   	   	   	  endif   
 	   	   	   	   	   	   	   	   	   	   	  |# fp3.en   
 	   	   	   	   	  get.lot.price(  	  tdinv700.item,   
 |  	   	   	   	   	   	   	  var.whinr110.clot,  	   	  |# fp3.o   
 	   	   	   	   	   	   	  lot.serial,  	   	   	  |# fp3.n   
 	   	   	   	   	   	   	  var.whina112.qstk,   
 	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 	   	   	   	   	   	   	  false,  	  |# FP5.n   
 	   	   	   	   	   	   	  true,   
 	   	   	   	   	   	   	  false)   
 	   	   	   	  endif   
 	   	   	  else   
 	   	   	   	  split.up.lots.inventory()   
 	   	   	  endif   
 	   	  else   
 	  	  	 |*  var.whinr110.valm  =  1 	  	  	 |# 2043803_2.n   
 	   	   	  dump 1  	   	   	   	   	   	   	   	  |# 800  -  145084.en   
 	   	   	  var.whina112.qstk  =  abs(tdinv700.quan)   
 	   	   	  receipt.counter  =  receipt.counter  +  1   
 	   	   	  to.be.received  =  to.be.received  -  abs(tdinv700.quan)   
 	   	   	  if to.be.received  >=  onhand.inventory then   
 	   	   	   	  |*  totally consumed   
 	   	   	   	  var.whina112.qskt  =  0.0   
 	   	   	  else   
 	   	   	   	  if var.whina112.qskt  >  0 then   
 	   	   	   	   	  |*  not consumed   
 	   	   	   	   	  var.whina112.qskt  =  abs(tdinv700.quan)   
 	   	   	   	  else   
 	   	   	   	   	  |*  partially consumed   
 	   	   	   	   	  var.whina112.qskt  =  onhand.inventory  -  to.be.received   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	  dump 3   
 	   	   	   	   	   	   	   	  |# fp3.so   
 |  	   	   	  if isspace(var.whinr110.clot) then  	   	   	   	   	  |# TELAIR.n   
 |  	   	   	   	  get.standard.cost.price(tdinv700.item, abs(tdinv700.quan),   
 | |  	   	   	   	   	   	   	  tdinv700.trdt, true, false)  	   	  |# TELAIR.o   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt, true, false)  	  |# TELAIR.sn   
 |  	   	   	  else   
 |  	   	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot, abs(tdinv700.quan),   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt, true, false)   
 |  	   	   	  endif  	   	   	   	   	   	   	   	   	  |# TELAIR.en   
 	   	   	   	   	   	   	   	  |# fp3.eo   
 	   	   	   	   	   	   	   	  |# fp3.sn   
 | 	   	   	  if isspace(var.whinr110.clot) and 	 |#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,  	  |# FP5.n   
 | 	   	   	   	   	   	  true,   
 | 	   	   	   	   	   	  false)   
 | 	   	   	  endif  	  	  	  	 |#2043803_2.eo   
 	   	   	   	   	   	   	   	  |# fp3.en   
 	   	  endif  	   	   	   	   	   	   	   	   	  |# 800  -  145084.n   
 	  else   
 	   	  dump 1  	   	   	   	   	   	   	   	   	  |# 800  -  145084.n   
 	   	  remain.quan  =  abs(tdinv700.quan)   
 	   	  if arr.whina112.qskt(i)  =  0 then   
 	   	   	  if tdinv000.nega  =  tcyesno.yes then   
 	   	   	   	  dump 11   
 	   	   	   	  hold.negative  =  hold.negative  +  abs(tdinv700.quan)   
 	   	   	   	   	   	   	   	  |# fp3.so   
 |  	   	   	   	  if isspace(var.whinr110.clot) then  	   	   	  |# TELAIR.n   
 |  	   	   	   	   	  get.standard.cost.price(tdinv700.item, abs(tdinv700.quan),   
 | |  	   	   	   	   	   	   	   	  tdinv700.trdt, false, true) |# TELAIR.o   
 |  	   	   	   	   	   	   	   	  hold.tdinv700.trdt, false, true) |# TELAIR.sn   
 |  	   	   	   	  else   
 |  	   	   	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot, abs(tdinv700.quan),   
 |  	   	   	   	   	   	   	   	  hold.tdinv700.trdt, false, true)   
 |  	   	   	   	  endif  	   	   	   	   	   	   	  |# TELAIR.en   
 	   	   	   	   	   	   	   	  |# fp3.eo   
 	   	   	   	   	   	   	   	  |# fp3.sn   
 | 	   	   	   	  if isspace(var.whinr110.clot) and |#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,  	  |# FP5.n   
 	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	  true)   
 	   	   	   	  endif   
 	   	   	   	   	   	   	   	  |# fp3.en   
 	   	   	  endif   
 	   	   	  |*  corrupt data: more issued then received   
 	   	   	  continue   
 	   	  endif   
 	   	  repeat   
 	   	   	  if remain.quan  <=  arr.whina112.qskt(i) then   
 	   	   	   	  var.whina114.trdt  =  arr.whina112.trdt(1,i)   
 	   	   	   	  var.whina114.seqn  =  arr.whina112.seqn(i)   
 	   	   	   	  var.whina114.sern  =  prev.sern  +  1   
 	   	   	   	  var.whina114.qstk  =  remain.quan   
 	   	   	   	  arr.whina112.qskt(i)  =  arr.whina112.qskt(i)  -  remain.quan   
 	   	   	   	  remain.quan  =  0   
 	   	   	   	  prev.sern  =  prev.sern  +  1   
 	   	   	  else   
 	   	   	   	  var.whina114.trdt  =  arr.whina112.trdt(1,i)   
 	   	   	   	  var.whina114.seqn  =  arr.whina112.seqn(i)   
 	   	   	   	  var.whina114.sern  =  prev.sern  +  1   
 	   	   	   	  var.whina114.qstk  =  arr.whina112.qskt(i)   
 	   	   	   	  remain.quan  =  remain.quan  -  arr.whina112.qskt(i)   
 	   	   	   	  arr.whina112.qskt(i)  =  0   
 	   	   	  endif   
 	   	   	  dump 4   
 	   	   	   	   	   	   	   	  |# fp3.so   
 |  	   	   	  if isspace(var.whinr110.clot) then  	   	   	   	  |# TELAIR.n   
 |  	   	   	   	  get.standard.cost.price(tdinv700.item, var.whina114.qstk,   
 | |  	   	   	   	   	   	   	  tdinv700.trdt, false, false)  	  |# TELAIR.o   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt, false, false)  	  |# TELAIR.sn   
 |  	   	   	  else   
 |  	   	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot, var.whina114.qstk,   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt, false, false)   
 |  	   	   	  endif  	   	   	   	   	   	   	   	  |# TELAIR.en   
 	   	   	   	   	   	   	   	  |# fp3.eo   
 	   	   	   	   	   	   	   	  |# fp3.sn   
 |  	   	   	  if isspace(var.whinr110.clot) and |#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,  	  |# FP5.n   
 	   	   	   	   	   	  false,   
 	   	   	   	   	   	  false)   
 	   	   	  endif   
 	   	   	   	   	   	   	   	  |# fp3.en   
 	   	   	  if arr.whina112.qskt(i)  =  0 then   
 	   	   	   	  prev.sern  =  0   
 	   	   	   	  i  =  i  +  1   
 	   	   	  endif   
 	   	   	  if remain.quan  >  0 and arr.whina112.qskt(i)  =  0 then   
 	   	   	   	  if tdinv000.nega  =  tcyesno.yes then   
 	   	   	   	   	  dump 11   
 	   	   	   	   	  hold.negative  =  hold.negative  +     
 	   	   	   	   	   	   	  remain.quan   
 	   	   	   	   	   	   	   	  |# fp3.so   
 |  	   	   	   	   	  if isspace(var.whinr110.clot) then  	   	  |# TELAIR.n   
 |  	   	   	   	   	   	  get.standard.cost.price(   
 |  	   	   	   	   	   	   	  tdinv700.item,   
 |  	   	   	   	   	   	   	  remain.quan,   
 | |  	   	   	   	   	   	   	  tdinv700.trdt, false, true)  	  |# TELAIR.o   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt, false, true)  	  |# TELAIR.sn   
 |  	   	   	   	   	  else   
 |  	   	   	   	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot,   
 |  	   	   	   	   	   	   	  remain.quan,   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt, false, true)   
 |  	   	   	   	   	  endif  	   	   	   	   	   	  |# TELAIR.en   
 	   	   	   	   	   	   	   	  |# fp3.eo   
 	   	   	   	   	   	   	   	  |# fp3.sn   
 	   	   	   	   	   	   	  |#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,  	  |# FP5.n   
 	   	   	   	   	   	   	   	  false,   
 	   	   	   	   	   	   	   	  true)   
 	   	   	   	   	  endif   
 	   	   	   	   	   	   	   	  |# fp3.en   
 	   	   	   	  endif   
 	   	   	   	  |*  corrupt data: more issued then received   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  until remain.quan  =  0   
 	  endif   
 	   	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.sn   
 |  	  if receipt.counter  =  dummy.array.nr  -  1 then  	  |# 218323.so   
 |  	   	  receipt.counter  =  receipt.counter  +  1   
 |  	   	  hold.koor  =  var.whinr110.koor   
 |  	   	  hold.kost  =  var.whinr110.kost   
 |  	   	  hold.orno  =  var.whinr110.orno   
 |  	   	  hold.trdt  =  var.whinr110.trdt   
 |  	   	  hold.seqn  =  var.whinr110.seqn   
 |  	   	  hold.qstk  =  var.whinr110.qstk   
 |  	   	  hold.bpid  =  var.whinr110.bpid   
 |  	   	  hold.qhnd  =  var.whinr110.qhnd  	   	   	   	   	   	  |# 214224.n   
 |  	   	  itid  =  itid  +  1   
 |  	   	  var.whinr110.itid  =  edit$(itid,"999999999")   
 |  	   	  var.whinr110.itse  =  1   
 |  	   	  var.whinr110.koor  =  52  	  |*  adjustment order   
 |  	   	  var.whinr110.kost  =  1  	  |*  stock correction   
 |  	   	  var.whinr110.orno  =  "MIGRATION"    
 |  	   	  var.whinr110.trdt  =  arr.whina112.trdt(1,dummy.array.nr)   
 |  	   	  var.whinr110.seqn  =  999  	  |*  take care   
 |  	   	  var.whinr110.qstk  =  dummy.receipt.qty   
 |  	   	  var.whinr110.bpid  =  empty()   
 |  	   	   	   	   	   	  |# 800  -  142486.sn   
 | |  	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  +  var.whinr110.qstk  	   	  |# 214224.o   
 |  	   	  var.whinr110.qhnd  =  onhand.inventory  	   	   	   	   	  |# 214224.n   
 |  	   	   	   	   	   	  |# 800  -  142486.en   
 | |  	   	  dump 1  	   	   	   	   	   	   	   	  |# 800  -  145084.o   
 |  	   	   	   	   	   	   	   	   	  |# fp3.so   
 | |  	   	  if var.whinr110.valm  =  5 then  	   	   	   	   	  |# 800  -  145084.sn   
 |  	   	   	   	   	   	   	   	   	  |# fp3.eo   
 |  	   	   	   	   	   	   	   	   	  |# fp3.sn   
 |  	   	  if var.whinr110.valm  =  5 or var.whinr110.valm  =  6 then   
 |  	   	   	   	   	   	   	   	   	  |# fp3.en   
 |  	   	   	  var.whina112.qstk  =  dummy.receipt.qty   
 |  	   	   	  receipt.counter  =  receipt.counter  +  1   
 |  	   	   	  to.be.received  =  to.be.received  -  dummy.receipt.qty   
 |  	   	   	  if to.be.received  >=  onhand.inventory then   
 |  	   	   	   	  |*  totally consumed   
 |  	   	   	   	  dump 1   
 |  	   	   	   	  var.whina112.qskt  =  0.0   
 |  	   	   	   	  dump 3   
 |  	   	   	   	   	   	   	   	  |# fp3.so   
 | |  	   	   	   	  if isspace(var.whinr110.clot) then   
 | |  	   	   	   	   	  get.standard.cost.price(tdinv700.item, var.whina112.qstk,   
 | |  	   	   	   	   	   	   	   	  hold.tdinv700.trdt, true, false)   
 | |  	   	   	   	  else   
 | |  	   	   	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot, var.whina112.qstk,   
 | |  	   	   	   	   	   	   	   	  hold.tdinv700.trdt, true, false)   
 | |  	   	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp3.eo   
 |  	   	   	   	   	   	   	   	  |# fp3.sn   
 |  	   	   	   	  if isspace(var.whinr110.clot) and   
 |  	   	   	   	  isspace(var.whinr110.serl) then   
 |  	   	   	   	   	  get.standard.cost.price(   
 |  	   	   	   	   	   	   	  tdinv700.item,   
 |  	   	   	   	   	   	   	  var.whina112.qstk,   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 |  	   	   	   	   	   	   	  true,   
 |  	   	   	   	   	   	   	  false)   
 |  	   	   	   	  else   
 |  	   	   	   	   	  if not isspace(var.whinr110.serl) then   
 |  	   	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 |  	   	   	   	   	  else   
 |  	   	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 |  	   	   	   	   	  endif   
 |  	   	   	   	   	  get.lot.price(  	  tdinv700.item,   
 |  	   	   	   	   	   	   	  lot.serial,   
 |  	   	   	   	   	   	   	  var.whina112.qstk,   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 |  	   	   	   	   	   	   	  true,   
 |  	   	   	   	   	   	   	  false)   
 |  	   	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp3.en   
 |  	   	   	  else   
 |  	   	   	   	  split.up.lots.inventory()   
 |  	   	   	  endif   
 |  	   	  else   
 |  	   	   	  dump 1  	   	   	   	   	   	   	   	  |# 800  -  145084.en   
 |  	   	   	  to.be.received  =  to.be.received  -  dummy.receipt.qty   
 |  	   	   	  if to.be.received  >=  onhand.inventory then   
 |  	   	   	   	  |*  totally consumed   
 |  	   	   	   	  var.whina112.qskt  =  0.0   
 |  	   	   	  else   
 |  	   	   	   	  if var.whina112.qskt  >  0 then   
 |  	   	   	   	   	  |*  not consumed   
 |  	   	   	   	   	  var.whina112.qskt  =  dummy.receipt.qty   
 |  	   	   	   	  else   
 |  	   	   	   	   	  |*  partially consumed   
 |  	   	   	   	   	  var.whina112.qskt  =  onhand.inventory  -  to.be.received   
 |  	   	   	   	  endif   
 |  	   	   	  endif   
 |  	   	   	  var.whina112.qstk  =  dummy.receipt.qty   
 |  	   	   	  dump 3   
 |  	   	   	   	   	   	   	   	  |# fp3.sn   
 |  	   	   	  if not isspace(var.whinr110.serl) then  	  | serialized   
 |  	   	   	   	  dump 14   
 |  	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp3.en   
 |  	   	   	   	   	   	   	   	  |# fp3.so   
 | |  	   	   	  if isspace(var.whinr110.clot) then  	   	   	   	   	  |# TELAIR.n   
 | |  	   	   	   	  get.standard.cost.price(tdinv700.item, dummy.receipt.qty,   
 | |  	  |  	   	   	   	   	   	  tdinv700.trdt, true, false)  	   	  |# TELAIR.o   
 | |  	   	   	   	   	   	   	  hold.tdinv700.trdt, true, false)  	  |# TELAIR.sn   
 | |  	   	   	  else   
 | |  	   	   	   	  get.lot.price(tdinv700.item, var.whinr110.clot, dummy.receipt.qty,   
 | |  	   	   	   	   	   	   	  hold.tdinv700.trdt, true, false)   
 | |  	   	   	  endif  	   	   	   	   	   	   	   	   	  |# TELAIR.en   
 |  	   	   	   	   	   	   	   	  |# fp3.eo   
 |  	   	   	   	   	   	   	   	  |# fp3.sn   
 |  	   	   	  if isspace(var.whinr110.clot) and   
 |  	   	   	  isspace(var.whinr110.serl) then   
 |  	   	   	   	  get.standard.cost.price(   
 |  	   	   	   	   	   	   	  tdinv700.item,   
 |  	   	   	   	   	   	   	  dummy.receipt.qty,   
 |  	   	   	   	   	   	   	  hold.tdinv700.trdt,   
 |  	   	   	   	   	   	   	  true,   
 |  	   	   	   	   	   	   	  false)   
 |  	   	   	  else   
 |  	   	   	   	  if not isspace(var.whinr110.serl) then   
 |  	   	   	   	   	  lot.serial  =  var.whinr110.serl   
 |  	   	   	   	  else   
 |  	   	   	   	   	  lot.serial  =  var.whinr110.clot   
 |  	   	   	   	  endif   
 |  	   	   	   	  get.lot.price(  	  tdinv700.item,   
 |  	   	   	   	   	   	  lot.serial,   
 |  	   	   	   	   	   	  dummy.receipt.qty,   
 |  	   	   	   	   	   	  hold.tdinv700.trdt,   
 |  	   	   	   	   	   	  true,   
 |  	   	   	   	   	   	  false)   
 |  	   	   	  endif   
 |  	   	   	   	   	   	   	   	  |# fp3.en   
 |  	   	  endif  	   	   	   	   	   	   	   	   	   	  |# 800  -  145084.n   
 |  	   	  var.whinr110.koor  =  hold.koor   
 |  	   	  var.whinr110.kost  =  hold.kost   
 |  	   	  var.whinr110.orno  =  hold.orno   
 |  	   	  var.whinr110.trdt  =  hold.trdt   
 |  	   	  var.whinr110.seqn  =  hold.seqn   
 |  	   	  var.whinr110.qstk  =  hold.qstk   
 |  	   	  var.whinr110.bpid  =  hold.bpid   
 |  	   	  var.whinr110.qhnd  =  hold.qhnd  	   	   	   	   	   	  |# 214224.n   
 |  	  endif  	   	   	   	   	   	  |# 218323.eo   
 	   	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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   
 	   	  hold.negative  =  0.0   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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  	   	   	   	   	   	  |# 214852.n   
 |  	  var.whinr110.trdt  =  utc(tipcs700.trdt, tipcs700.trtm) |# 800  -  142000.o   
 |  	  var.whinr110.seqn  =  tipcs700.sern  +  1  	   	  |# 800  -  142000.o   
 	  var.whinr110.trdt  =  utc(tipcs700.trdt, 0)  	   	   	  |# 800  -  142000.sn   
 	   	   	   	   	   	   	   	   	  |# TELAIR.sn   
 	  hold.tipcs700.trdt  =  tipcs700.trdt   
 	  hold.tipcs700.trtm  =  tipcs700.trtm   
 	  hold.tipcs700.sern  =  tipcs700.sern   
 	   	   	   	   	   	   	   	   	  |# TELAIR.en   
 	  if check1.trdt  <>  tipcs700.trdt then   
 	   	  check1.trdt  =  tipcs700.trdt   
 	   	  var.whinr110.seqn  =  1   
 	  else   
 	   	  var.whinr110.seqn  =  var.whinr110.seqn  +  1   
 	  endif   
 	   	   	   	   	   	   	   	   	  |# 800  -  142000.en   
 	  var.whinr110.cprj  =  get.project(tipcs700.cprj)   
 	  if hold.cprj  <>  tipcs700.cprj or   
 |  	  hold.item  <>  tipcs700.item then  	   	   	   	   	  |# 214852.o   
 	  hold.item  <>  tipcs700.item or  	   	   	   	   	  |# 214852.n   
 	  hold.cwar  <>  keep.cwar then  	   	   	   	   	  |# 214852.n   
 	   	  stock  =  0.0 	  	  	  	  	  	 |*  2043803_4.n 	  	    
 	   	  var.whinr110.seqn  =  1  	   	   	   	   	  |# 800  -  142000.n   
 	   	  var.whinr110.qhnd  =  0.0  	   	   	  |# 800  -  142486.n   
 	   	  hold.cprj  =  tipcs700.cprj   
 	   	  hold.item  =  tipcs700.item   
 	   	  hold.cwar  =  keep.cwar  	   	   	   	   	   	  |# 214852.n   
 | 	   	  if tdilc000.iilc  =  tcyesno.no then |# 214852.n 	 |#2043803.o   
 |  	   	  select  	  tipcs021.stoc  	   	   	  |# 214852.o   
 	   	  select  	  tipcs021.stoc:stock, tipcs021.cwar,  	   	  |# 214852.n   
 	   	  	  	  tipcs021.kltc 	  	   	 |*  2043803_4.n   
 	   	  from  	  tipcs021   
 	   	  where  	  tipcs021._index1  =  {:hold.cprj, :hold.item}   
 	   	  as set with 1 rows   
 	   	  selectdo   
 	   	  endselect   
 | 	   	  else  	   	   	   	  |# 214852.sn |#2043803.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   
 	   	   	   	   	   	   	   	   	   	  |# 214852.en   
 	   	  var.whina112.qskt  =  0.0   
 	   	  to.be.received  =  0.0   
 	   	  issued  =  0.0   
 |  	   	  i  =  0  	   	   	   	   	  |# 218323.o   
 	   	  i  =  1  	   	   	   	   	   	  |# 218323.n   
 	   	  dummy.receipt.qty  =  0.0   
 	   	  dummy.array.nr  =  0   
 	   	  receipt.counter  =  0   
 	   	  set.mem(arr.whina112.trdt, "")    
 	   	  set.mem(arr.whina112.seqn, 0)   
 	   	  set.mem(arr.whina112.qskt, 0.0)   
 	   	   	   	   	   	   	   	   	   	   	  |# 214852.so   
 |  	   	  select  	  tipcs700._index1,   
 |  	   	   	  tipcs700.quan:curr.quan,   
 |  	   	   	  tipcs700.kost:curr.kost   
 |  	   	  from  	  tipcs700   
 |  	   	  where  	  tipcs700._index1  =  {:hold.cprj, :hold.item}   
 |  	   	  order by tipcs700._index1   
 |  	   	  selectdo   
 	   	   	   	   	   	   	   	   	   	   	  |# 214852.eo   
 	   	   	   	   	   	   	   	   	   	   	  |# 214852.sn   
 	   	  for k  =  1 to arr.len.tipcs700   
 	   	   	  if isspace(arr.tipcs700.cwar(1,k)) then   
 	   	   	   	  break   
 	   	   	  else   
 	   	   	   	  if arr.tipcs700.proc(k)  =  1 or   
 	   	   	   	  arr.tipcs700.cwar(1,k)  <>  keep.cwar then   
 	   	   	   	   	  continue   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	  found.trdt  =  arr.tipcs700.trdt(k)   
 	   	   	  found.trtm  =  arr.tipcs700.trtm(k)   
 	   	   	  found.sern  =  arr.tipcs700.sern(k)   
 	   	   	  select  	  tipcs700._index1,   
 	   	   	   	  tipcs700.quan:curr.quan,   
 	   	   	   	  tipcs700.kost:curr.kost   
 	   	   	  from  	  tipcs700   
 	   	   	  where  	  tipcs700._index1  =  {:keep.cprj, :keep.item, :found.trdt, :found.trtm, :found.sern}   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	  endselect   
 	   	   	   	   	   	   	   	   	   	   	  |# 214852.en   
 	   	   	   	   	   	   	   	   	   	   	  |# 800  -  142000.sn   
 	   	   	  if check2.item  <>  tipcs700.item or   
 	   	   	  check2.trdt  <>  tipcs700.trdt then   
 	   	   	   	  check2.item  =  tipcs700.item   
 	   	   	   	  check2.trdt  =  tipcs700.trdt   
 	   	   	   	  check.seqn  =  1   
 	   	   	  else   
 	   	   	   	  check.seqn  =  check.seqn  +  1   
 	   	   	  endif   
 	   	   	   	   	   	   	   	   	   	   	  |# 800  -  142000.en   
 	   	   	  if (curr.kost  =  tckost.stc.correction and curr.quan  >  0) or   
 	   	   	  ((curr.kost  =  tckost.pur.receipt or   
 	   	   	  curr.kost  =  tckost.prd.receipt or   
 	   	   	  curr.kost  =  tckost.rpl.receipt) and curr.quan  >  0) or   
 	   	   	  ((curr.kost  =  tckost.sls.delivery or   
 	   	   	  curr.kost  =  tckost.prd.mat.issue or   
 	   	   	  curr.kost  =  tckost.rpl.delivery) and curr.quan  <  0) or   
 	   	   	  (curr.kost  =  tckost.stc.transfer and curr.quan  >  0) then   
 	   	   	   	  to.be.received  =  to.be.received  +  abs(curr.quan)   
 	   	   	   	  i  =  i  +  1   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  |# array.len  =  array.len  +  100  	  |# 228714.o   
 	   	   	   	   	  array.len  =  array.len  +  200  	  |# 228714.n   
 	   	   	   	   	  alloc.mem(arr.whina112.trdt, 22, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.seqn, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.qskt, array.len)   
 	   	   	   	  endif   
 |  	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tipcs700.trdt, tipcs700.trtm) |# 800  -  142000.o   
 	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tipcs700.trdt, 0)  	   	  |# 800  -  142000.n   
 |  	   	   	   	  arr.whina112.seqn(i)  =  tipcs700.sern  +  1  	   	   	  |# 800  -  142000.o   
 	   	   	   	  arr.whina112.seqn(i)  =  check.seqn  	   	   	   	  |# 800  -  142000.n   
 	   	   	   	  arr.whina112.qskt(i)  =  abs(curr.quan)   
 	   	   	  else   
 	   	   	   	  issued  =  issued  +  abs(curr.quan)   
 	   	   	  endif   
 |  	   	  selecteos  	   	   	   	   	   	   	   	  |# 214852.o   
 	   	  endfor  	   	   	   	   	   	   	   	   	  |# 214852.n   
 |  	   	   	  onhand.inventory  =  max(to.be.received  -  issued, tipcs021.stoc)  	  |# 214852.o   
 	   	   	  onhand.inventory  =  max(to.be.received  -  issued, stock)  	   	  |# 214852.n   
 	   	   	  if onhand.inventory  >  to.be.received  -  issued then   
 	   	   	   	  |*  create dummy receipt   
 	   	   	   	  dummy.receipt.qty  =  onhand.inventory  -  to.be.received  +  issued   
 	   	   	   	  to.be.received  =  to.be.received  +  dummy.receipt.qty   
 |  	   	   	   	  i  =  i  +  1  	   	   	   	  |# 218323.o   
 	   	   	   	  i  =  1  	   	   	   	   	  |# 218323.n   
 	   	   	   	  if i  >  array.len then   
 	   	   	   	   	  |# array.len  =  array.len  +  100  	  |# 228714.o   
 	   	   	   	   	  array.len  =  array.len  +  200  	  |# 228714.n   
 	   	   	   	   	  alloc.mem(arr.whina112.trdt, 22, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.seqn, array.len)   
 	   	   	   	   	  alloc.mem(arr.whina112.qskt, array.len)   
 	   	   	   	  endif   
 |  	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tipcs700.trdt, tipcs700.trtm) |# 800  -  142000.o   
 	   	   	   	   	   	   	   	   	  |# 218323.so   
 |  	   	   	   	  arr.whina112.trdt(1,i)  =  utc(tipcs700.trdt, 0)  	   	  |# 800  -  142000.n   
 |  	   	   	   	  arr.whina112.seqn(i)  =  999  	  |*  take care   
 	   	   	   	   	   	   	   	   	  |# 218323.eo   
 	   	   	   	   	   	   	   	   	  |# 218323.sn   
 	   	   	   	  arr.whina112.trdt(1,i)  =  utc( date.to.num(1980,1,1), 0)   
 	   	   	   	  arr.whina112.seqn(i)  =  1   
 	   	   	   	   	   	   	   	   	  |# 218323.en   
 	   	   	   	  arr.whina112.qskt(i)  =  dummy.receipt.qty   
 	   	   	   	  dummy.array.nr  =  i   
 	   	   	   	   	   	   	   	   	  |# 218323.sn   
 	   	   	   	  create.tipcs700.correction.record()   
 	   	   	  else   
 	   	   	   	  i  =  2   
 	   	   	   	   	   	   	   	   	  |# 218323.en   
 	   	   	  endif   
 |  	   	  endselect  	   	   	   	   	   	   	   	   	  |# 214852.o  	   	   	   	  i  =  1   
 	   	  prev.sern  =  0   
 	  endif   
 	     
 	  var.whinr110.qstk  =  tipcs700.quan   
 	  var.whinr110.bpid  =  empty()   
 	  var.whinr110.srnb  =  0   
 	  var.whinr110.shpm  =  " "  	   	   	   	   	   	  |# 202924.n   
 	  var.whinr110.shpo  =  0  	   	   	   	   	   	   	  |# 202924.n   
 	  var.whinr110.rcno  =  ""  	   	   	   	   	   	   	  |# 227896.sn    
 	  var.whinr110.rcln  =  0  	   	   	   	   	   	   	  |# 227896.en   
 	  on case tipcs700.koor   
 	   	  case tckoor.act.pur :   
 	   	   	  if not get.business.partner(tipcs700.rlcd, bcstc.orgn.suno, o.mess) then   
 	   	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	  get.purchase.order.line.data(  	   	  |# 213329.so   
 	   	   	   	  false,  	   	  | inv   
 	   	   	   	  tipcs700.orno,   
 	   	   	   	  tipcs700.pono,   
 	   	   	   	  hold.tipcs700.trdt,   
 	   	   	   	  hold.tipcs700.trtm,   
 	   	   	   	  hold.tipcs700.sern,   
 	   	   	   	  tipcs700.cprj,   
 	   	   	   	  tipcs700.item,  	     
 	   	   	   	  tipcs700.quan,   
 	   	   	   	  var.whinr110.rcno,  	   	  |# 227896.sn   
 	   	   	   	  var.whinr110.rcln,  	   	  |# 227896.en   
 	   	   	   	  var.whinr110.srnb,   
 	   	   	   	  bom.line)  	   	   	  |# 213329.eo   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	   	  if tipcs700.quan  <  0 then   
 |  	   	   	   	  get.return.purchase.order.line.data( |# 213329.so   
 |  	   	   	   	   	  false,  	   	  | inv   
 |  	   	   	   	   	  tipcs700.orno,   
 |  	   	   	   	   	  tipcs700.pono,   
 |  	   	   	   	   	  hold.tipcs700.trdt,   
 |  	   	   	   	   	  hold.tipcs700.trtm,   
 |  	   	   	   	   	  hold.tipcs700.sern,   
 |  	   	   	   	   	  tipcs700.cprj,   
 |  	   	   	   	   	  tipcs700.item,  	     
 |  	   	   	   	   	  tipcs700.quan,   
 |  	   	   	   	   	  var.whinr110.srnb,   
 |  	   	   	   	   	  bom.line)  	   	  |# 213329.eo   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	   	  break   
 	   	  case tckoor.act.sls :   
 	   	   	  if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.so   
 |  	   	   	  var.whinr110.srnb  =  determine.sales.order.sequence(  	  false,  	  | pcs  	  |# 800  -  143063.n   
 |  	   	   	   	   	   	   	   	   	   	  tipcs700.orno,   
 |  	   	   	   	   	   	   	   	   	   	  tipcs700.pono,   
 |  	   	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.so   
 | |  	   	   	   	   	   	   	   	   	   	  tipcs700.trdt,   
 | |  	   	   	   	   	   	   	   	   	   	  tipcs700.trtm,  	  |# 800  -  143063.n   
 | |  	   	   	   	   	   	   	   	   	   	  tipcs700.sern,  	  |# 800  -  143063.n   
 |  	   	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.eo   
 |  	   	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.sn   
 |  	   	   	   	   	   	   	   	   	   	  hold.tipcs700.trdt,   
 |  	   	   	   	   	   	   	   	   	   	  hold.tipcs700.trtm,   
 |  	   	   	   	   	   	   	   	   	   	  hold.tipcs700.sern,   
 |  	   	   	   	   	   	   	   	   	   	   	   	   	  |# TELAIR.en   
 |  	   	   	   	   	   	   	   	   	   	  tipcs700.cprj,  	  |# 800  -  143063.n   
 |  	   	   	   	   	   	   	   	   	   	  tipcs700.quan)  	  |# 800  -  143063.n   
 	   	   	   	   	   	   	   	  |# SL204550.eo  	   	   	   	   	   	   	   	  |# 202924.sn   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	   	  get.sales.order.line.data(   
 	   	   	   	   	  true,  	   	  | inv   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  hold.tipcs700.trdt,   
 	   	   	   	   	  hold.tipcs700.trtm,   
 	   	   	   	   	  hold.tipcs700.sern,   
 	   	   	   	   	  "", |*   Project    
 	   	   	   	   	  tipcs700.item,   
 	   	   	   	   	  tipcs700.quan,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	  bom.line)   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	  |*  shipment  /  line number are needed for COGS determination   
 	   	  |*  filling is conform include ibcswh0007   
 	   	   	  if tipcs700.quan  >  0 then   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  var.whinr110.srnb,   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  bom.line,   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  else   
 	   	   	   	   	   	   	   	  |# SL204550.en  	     
 	   	   	   	  var.whinr110.shpm  =  edit$(tipcs700.orno, "999999")  &   edit$(tipcs700.pono, "999")    
 	   	   	   	  var.whinr110.shpo  =  var.whinr110.srnb   
 	   	   	   	  if var.whinr110.shpo  =  0 then   
 	   	   	   	   	  var.whinr110.shpo  =  10   
 	   	   	   	  endif   
 	   	   	   	  endif  	   	   	   	  |# SL204550.en   
 	   	   	  endif   
 	   	   	   	   	   	   	   	   	   	   	   	  |# 202924.en   
 	   	   	  break   
 	   	  case tckoor.sma.order :   
 	   	   	  if not get.business.partner(tipcs700.rlcd, bcstc.orgn.cuno, o.mess) then   
 	   	   	   	  var.whinr110.bpid  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	   	  if tipcs700.quan  >  0 then   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,   
 	   	   	   	   	  0,  	   	   	  |*  sequence   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  0,  	   	   	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	   	  break   
 	   	   	   	   	   	   	   	   	   	  |# 200  -  101937.sn   
 	   	  case tckoor.pcs.wrh:   
 	   	   	  tipcs700.pono  =  10   
 	   	   	  var.whinr110.srnb  =  1   
 	   	   	   	   	   	   	   	  |# SL204550.sn   
 	   	   	  if tipcs700.quan  >  0 then   
 	   	   	   	  errmess  =  ""    
 	   	   	   	  get.shipment.number.and.line(   
 	   	   	   	   	  tipcs700.koor,   
 	   	   	   	   	  tipcs700.orno,   
 	   	   	   	   	  tipcs700.pono,  
 	   	   	   	   	  0,  	   	   	  |*  sequence   
 	   	   	   	   	   	   	   	  |# 243681.sn   
 	   	   	   	   	  0,  	  |*  Outbound Sequence   
 	   	   	   	   	   	   	   	  |# 243681.en   
 	   	   	   	   	  0,  	  |*  bom line   
 	   	   	   	   	  errmess)   
 	   	   	   	  if isspace(errmess) then   
 	   	   	   	   	  var.whinr110.shpm  =  bcswh008.shpm   
 	   	   	   	   	  var.whinr110.shpo  =  bcswh008.shln   
 	   	   	   	  endif   
 	   	   	  endif   
 	   	   	   	   	   	   	   	  |# SL204550.en   
 	   	   	  break   
 	   	   	   	   	   	   	   	   	   	  |# 200  -  101937.en   
 	  endcase   
 	  if tipcs700.prst  <>  empty then   
 	   	  var.whinr110.prnt  =  tipcs700.prst   
 	  else   
 	   	  var.whinr110.prnt  =  tcyesno.no   
 	  endif   
 	  var.whinr110.qstk  =  tipcs700.quan   
 	  if tipcs700.kost  =  tckost.stc.transfer then   
 	   	  if (tipcs700.quan  <  0) then   
 	   	   	  var.whinr110.qstk  =  abs (tipcs700.quan)   
 	   	  endif   
 	  endif   
 	  var.whinr110.koor  =  convert.tckoor(tipcs700.koor, tipcs700.orno)   
 	  var.whinr110.kost  =  convert.tckost(tipcs700.kost, tipcs700.quan)   
 	  if var.whinr110.koor  =  51 then | cycle count   
 	   	  var.whinr110.orno  =  get.new.cycle.count.order.number(   
 	   	   	   	   	  tipcs700.orno, tipcs021.cwar)   
 	  else   
 	   	  var.whinr110.orno  =  convert.number(   
 	   	   	   	   	  convert.tckoor.to.bcckon(tipcs700.koor), tipcs700.orno)   
 	  endif   
 	  itid  =  itid  +  1   
 	  var.whinr110.itid  =  edit$(itid,"999999999")   
 	  var.whinr110.itse  =  1   
 	   	   	   	   	   	  |# 800  -  142486.sn   
 	  |*  calculate quantity after transaction because it is not reliable in Baan4   
 	  if var.whinr110.kost  =  1 or  	   	  | tckost.stc.correction   
 	  var.whinr110.kost  =  3 then  	   	  | tckost.receipt   
 	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  +  var.whinr110.qstk   
 	  endif   
 	  if var.whinr110.kost  =  5 then  	   	  | tckost.issue   
 	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  -  var.whinr110.qstk   
 	  endif   
 	   	   	   	   	   	  |# 800  -  142486.en   
 	  var.whinr110.clot  =  empty()  	   	   	   	   	  |# TELAIR.n   
 	  var.whinr110.serl  =  empty()  	   	   	   	   	  |# fp3.n   
 	  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   
 	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.so   
 |  	  if receipt.counter  =  dummy.array.nr  -  1 then   
 |  	   	  receipt.counter  =  receipt.counter  +  1   
 |  	   	  hold.koor  =  var.whinr110.koor   
 |  	   	  hold.kost  =  var.whinr110.kost   
 |  	   	  hold.orno  =  var.whinr110.orno   
 |  	   	  hold.trdt  =  var.whinr110.trdt   
 |  	   	  hold.seqn  =  var.whinr110.seqn   
 |  	   	  hold.qstk  =  var.whinr110.qstk   
 |  	   	  itid  =  itid  +  1   
 |  	   	  var.whinr110.itid  =  edit$(itid,"999999999")   
 |  	   	  var.whinr110.itse  =  1   
 |  	   	  var.whinr110.koor  =  52  	  |*  adjustment   
 |  	   	  var.whinr110.kost  =  1  	  |*  stock correction   
 |  	   	  var.whinr110.trdt  =  arr.whina112.trdt(1,dummy.array.nr)   
 |  	   	  var.whinr110.orno  =  "MIGRATION"    
 |  	   	  var.whinr110.seqn  =  999  	  |*  take care   
 |  	   	  var.whinr110.qstk  =  dummy.receipt.qty   
 |  	   	   	   	   	   	  |# 800  -  142486.sn   
 |  	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  +  var.whinr110.qstk   
 |  	   	   	   	   	   	  |# 800  -  142486.en   
 |  	   	  dump 2   
 |  	   	  to.be.received  =  to.be.received  -  dummy.receipt.qty   
 |  	   	  if to.be.received  >=  onhand.inventory then   
 |  	   	   	  |*  totally consumed   
 |  	   	   	  var.whina112.qskt  =  0.0   
 |  	   	  else   
 |  	   	   	  if var.whina112.qskt  >  0 then   
 |  	   	   	   	  |*  not consumed   
 |  	   	   	   	  var.whina112.qskt  =  dummy.receipt.qty   
 |  	   	   	  else   
 |  	   	   	   	  |*  partially consumed   
 |  	   	   	   	  var.whina112.qskt  =  onhand.inventory  -  to.be.received   
 |  	   	   	  endif   
 |  	   	  endif   
 |  	   	  var.whina112.qstk  =  dummy.receipt.qty   
 |  	   	  dump 5   
 |  	   	  get.customized.cost.price(tipcs700.cprj, tipcs700.item,   
 |  	   	   	   	   	   	  dummy.receipt.qty, true)   
 |  	   	  var.whinr110.koor  =  hold.koor   
 |  	   	  var.whinr110.kost  =  hold.kost   
 |  	   	  var.whinr110.orno  =  hold.orno   
 |  	   	  var.whinr110.trdt  =  hold.trdt   
 |  	   	  var.whinr110.seqn  =  hold.seqn   
 |  	   	  var.whinr110.qstk  =  hold.qstk   
 |  	  endif   
 	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.eo   
 	  if (tipcs700.kost  =  tckost.stc.correction and tipcs700.quan  >  0) or   
 	  ((tipcs700.kost  =  tckost.pur.receipt or   
 	  tipcs700.kost  =  tckost.prd.receipt or   
 	  tipcs700.kost  =  tckost.rpl.receipt) and tipcs700.quan  >  0) or   
 	  ((tipcs700.kost  =  tckost.sls.delivery or   
 	  tipcs700.kost  =  tckost.prd.mat.issue or   
 	  tipcs700.kost  =  tckost.rpl.delivery) and tipcs700.quan  <  0) or   
 	  (tipcs700.kost  =  tckost.stc.transfer and tipcs700.quan  >  0) then   
 	   	  var.whina112.qstk  =  abs(tipcs700.quan)   
 	   	  receipt.counter  =  receipt.counter  +  1   
 	   	  to.be.received  =  to.be.received  -  abs(tipcs700.quan)   
 	   	  if to.be.received  >=  onhand.inventory then   
 	   	   	  |*  totally consumed   
 	   	   	  var.whina112.qskt  =  0.0   
 	   	  else   
 	   	   	  if var.whina112.qskt  >  0 then   
 	   	   	   	  |*  not consumed   
 	   	   	   	  var.whina112.qskt  =  abs(tipcs700.quan)   
 	   	   	  else   
 	   	   	   	  |*  partially consumed   
 	   	   	   	  var.whina112.qskt  =  onhand.inventory  -  to.be.received   
 	   	   	  endif   
 	   	  endif   
 	   	  dump 5   
 	   	  get.customized.cost.price(tipcs700.cprj, tipcs700.item,   
 	   	   	   	   	   	  abs(tipcs700.quan), true)   
 	  else   
 	   	  remain.quan  =  abs(tipcs700.quan)   
 	   	  if arr.whina112.qskt(i)  =  0 then   
 	   	   	  |*  corrupt data: more issued then received   
 	   	   	  continue   
 	   	  endif   
 	   	  repeat   
 	   	   	  if remain.quan  <=  arr.whina112.qskt(i) then   
 	   	   	   	  var.whina114.trdt  =  arr.whina112.trdt(1,i)   
 	   	   	   	  var.whina114.seqn  =  arr.whina112.seqn(i)   
 	   	   	   	  var.whina114.sern  =  prev.sern  +  1   
 	   	   	   	  var.whina114.qstk  =  remain.quan   
 	   	   	   	  arr.whina112.qskt(i)  =  arr.whina112.qskt(i)  -  remain.quan   
 	   	   	   	  remain.quan  =  0   
 	   	   	   	  prev.sern  =  prev.sern  +  1   
 	   	   	  else   
 	   	   	   	  var.whina114.trdt  =  arr.whina112.trdt(1,i)   
 	   	   	   	  var.whina114.seqn  =  arr.whina112.seqn(i)   
 	   	   	   	  var.whina114.sern  =  prev.sern  +  1   
 	   	   	   	  var.whina114.qstk  =  arr.whina112.qskt(i)   
 	   	   	   	  remain.quan  =  remain.quan  -  arr.whina112.qskt(i)   
 	   	   	   	  arr.whina112.qskt(i)  =  0   
 	   	   	  endif   
 	   	   	  dump 6   
 	   	   	  get.customized.cost.price(tipcs700.cprj, tipcs700.item,   
 	   	   	   	   	   	   	  var.whina114.qstk, false)   
 	   	   	  if arr.whina112.qskt(i)  =  0 then   
 	   	   	   	  prev.sern  =  0   
 	   	   	   	  i  =  i  +  1   
 	   	   	  endif   
 	   	   	  if remain.quan  >  0 and arr.whina112.qskt(i)  =  0 then   
 	   	   	   	  |*  corrupt data: more issued then received   
 	   	   	   	  break   
 	   	   	  endif   
 	   	  until remain.quan  =  0   
 	  endif   
 	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.sn   
 |  	  if receipt.counter  =  dummy.array.nr  -  1 then  	   	  | 218323.so   
 |  	   	  receipt.counter  =  receipt.counter  +  1   
 |  	   	  hold.koor  =  var.whinr110.koor   
 |  	   	  hold.kost  =  var.whinr110.kost   
 |  	   	  hold.orno  =  var.whinr110.orno   
 |  	   	  hold.trdt  =  var.whinr110.trdt   
 |  	   	  hold.seqn  =  var.whinr110.seqn   
 |  	   	  hold.qstk  =  var.whinr110.qstk   
 |  	   	  hold.qhnd  =  var.whinr110.qhnd  	   	   	   	  |# 214224.n   
 |  	   	  itid  =  itid  +  1   
 |  	   	  var.whinr110.itid  =  edit$(itid,"999999999")   
 |  	   	  var.whinr110.itse  =  1   
 |  	   	  var.whinr110.koor  =  52  	  |*  adjustment   
 |  	   	  var.whinr110.kost  =  1  	  |*  stock correction   
 |  	   	  var.whinr110.trdt  =  arr.whina112.trdt(1,dummy.array.nr)   
 |  	   	  var.whinr110.orno  =  "MIGRATION"    
 |  	   	  var.whinr110.seqn  =  999  	  |*  take care   
 |  	   	  var.whinr110.qstk  =  dummy.receipt.qty   
 |  	   	   	   	   	   	  |# 800  -  142486.sn   
 | |  	   	  var.whinr110.qhnd  =  var.whinr110.qhnd  +  var.whinr110.qstk  	  |# 214224.o   
 |  	   	  var.whinr110.qhnd  =  onhand.inventory  	   	   	   	  |# 214224.n   
 |  	   	   	   	   	   	  |# 800  -  142486.en   
 |  	   	  dump 2   
 |  	   	  to.be.received  =  to.be.received  -  dummy.receipt.qty   
 |  	   	  if to.be.received  >=  onhand.inventory then   
 |  	   	   	  |*  totally consumed   
 |  	   	   	  var.whina112.qskt  =  0.0   
 |  	   	  else   
 |  	   	   	  if var.whina112.qskt  >  0 then   
 |  	   	   	   	  |*  not consumed   
 |  	   	   	   	  var.whina112.qskt  =  dummy.receipt.qty   
 |  	   	   	  else   
 |  	   	   	   	  |*  partially consumed   
 |  	   	   	   	  var.whina112.qskt  =  onhand.inventory  -  to.be.received   
 |  	   	   	  endif   
 |  	   	  endif   
 |  	   	  var.whina112.qstk  =  dummy.receipt.qty   
 |  	   	  dump 5   
 |  	   	  get.customized.cost.price(tipcs700.cprj, tipcs700.item,   
 |  	   	   	   	   	   	  dummy.receipt.qty, true)   
 |  	   	  var.whinr110.koor  =  hold.koor   
 |  	   	  var.whinr110.kost  =  hold.kost   
 |  	   	  var.whinr110.orno  =  hold.orno   
 |  	   	  var.whinr110.trdt  =  hold.trdt   
 |  	   	  var.whinr110.seqn  =  hold.seqn   
 |  	   	  var.whinr110.qstk  =  hold.qstk   
 |  	   	  var.whinr110.qhnd  =  hold.qhnd  	   	   	   	  |# 214224.n   
 |  	  endif  	   	   	   	   	   	  |# 218323.eo   
 	   	   	   	   	   	   	   	   	   	  |# 800  -  144866.en
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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  	   	   	  |# 1161706.o   
 	   	  if fifo.lifo.item(  	  tdltc001.cprj,  	   	  |# 1161706.sn   
 	   	   	   	   	  tdltc001.item) then   
 	   	   	  lot.date  =  tdltc001.oudt   
 	   	  else   
 	   	   	  lot.date  =  tdltc001.ardt   
 	   	  endif  	   	   	   	   	  |# 1161706.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)  	  	  	 |#1898361.n   
 	   	   	  Dump 4  	   	  |   *  Serials   
 	   	  endselect   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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:61
:VERS:B4ct
: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
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:dm
:TCMOD:chm
:TFLNO:040
:SCPAC:ti
:SCMOD:edm
:SFLNO:310
:ICOD:D
:QURY:START
	 select tiedm303.prcd, tiedm303.step, tiedm303.txta  
 	 from 	 tiedm303  
 	 where 	 tiedm303.prcd =  :tiedm310.prcd  
 	 selectdo  
 	 	 select 	 tiedm302.dcsa  
 	 	 from 	 tiedm302  
 	 	 where 	 tiedm302._index1 =  {:tiedm303.step}  
 	 	 selectdo  
 	 	 endselect  
 	 	 dump 1  
 	 endselect
:QURY:END
:TEXT:

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

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

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

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

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

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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   
 	  else   
 	   	  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   
 	   	  |   *  One  -  Time BP should not get a Parent BP filled.   
 	   	   	  var.tccom100.prbp  =  ""   
 	   	  else   
 	   	   	  var.tccom100.prbp  =  hold.tccom100.prbp   
 	   	  endif   
 	  endif   
 	  if tccom010.inrl  =  empty then   
 	   	  var.tccom100.inrl  =  tcyesno.no   
 	  else   
 	   	  var.tccom100.inrl  =  tccom010.inrl   
 	  endif   
 	  on case tccom010.cnpa   
 	  case tccnpa.prospect:   
 	   	  var.tccom100.prst  =  1 | potential   
 	   	  var.tccom111.bpst  =  1 | active   
 	   	  var.tccom112.itst  =  1 | active   
 	   	  var.tccom114.bpst  =  1 | active   
 	   	  break   
 	  case tccnpa.normal:   
 	   	  var.tccom100.prst  =  2 | active   
 	   	  var.tccom111.bpst  =  1 | active   
 	   	  var.tccom112.itst  =  1 | active   
 	   	  var.tccom114.bpst  =  1 | active   
 	   	  break   
 	  case tccnpa.doubtful:   
 	   	  var.tccom100.prst  =  2 | active   
 	   	  var.tccom111.bpst  =  1 | active   
 	   	  var.tccom112.itst  =  3 | doubtful   
 	   	  var.tccom114.bpst  =  1 | active   
 	   	  break   
 	  case tccnpa.blocked:   
 	   	  var.tccom100.prst  =  3 | inactive   
 	   	  var.tccom111.bpst  =  2 | inactive   
 	   	  var.tccom112.itst  =  2 | inactive   
 	   	  var.tccom114.bpst  =  2 | inactive   
 	   	  break   
 	  endcase   
 	  if ( tccom010.scom  =  tcyesno.yes ) then   
 	   	  var.tccom110.scon  =  4   
 	  else   
 	   	  var.tccom110.scon  =  1   
 	  endif   
 	  if get.addresses("tccom010", tccom010.cuno, o.mess) then   
 	   	  var.tccom010.cadr  =  ""   
 	  else   
 	   	  var.tccom010.cadr  =  bcstc004.cadr   
 	  endif   
 	  temp.key.ccor(1;9)  =  " "   
 	  temp.key.cdel(1;9)  =  " "   
 	  if (not isspace(tccom010.ccor)) then   
 	   	  temp.key.ccor(1;6)  =  tccom010.cuno   
 	   	  temp.key.ccor(7;9)  =  tccom010.ccor   
 	   	  if get.addresses("tccom012", temp.key.ccor, o.mess) then   
 	   	   	  var.tccom110.cadr  =  var.tccom010.cadr   
 	   	  else   
 	   	   	  var.tccom110.cadr  =  bcstc004.cadr   
 	   	  endif   
 	  else   
 	   	  var.tccom110.cadr  =  var.tccom010.cadr   
 	  endif   
 	  if (not isspace(tccom010.cdel)) then   
 	   	  temp.key.cdel(1;6)  =  tccom010.cuno   
 	   	  temp.key.cdel(7;9)  =  tccom010.cdel   
 	   	  if get.addresses("tccom013", temp.key.cdel, o.mess) then   
 	   	   	  var.tccom111.cadr  =  var.tccom010.cadr   
 	   	  else   
 	   	   	  var.tccom111.cadr  =  bcstc004.cadr   
 	   	  endif   
 	  else   
 	   	  var.tccom111.cadr  =  var.tccom010.cadr   
 	  endif   
 	  if get.cross.reference.for.contact.code("tccom010a",tccom010.cuno, o.mess) then   
 	   	  var.tccom110.ccnt  =  ""   
 	  else   
 	   	  var.tccom110.ccnt  =  bcstc005.ccnt   
 	  endif   
 	  if get.cross.reference.for.contact.code("tccom010",tccom010.cuno, o.mess) then   
 	   	  var.tccom112.ccnt  =  ""   
 	  else   
 	   	  var.tccom112.ccnt  =  bcstc005.ccnt   
 	  endif   
 	  if isspace(tccom010.pctx)  	  or   
 	  isspace(var.tccom100.prbp)  	  |# 200003.n   
 	  then   
 	   	  var.tccom100.bptx  =  ""   
 	  else   
 	   	  var.tccom100.bptx  =  get.business.partner.code(tccom010.pctx, bcstc.orgn.cuno, o.mess)   
 	  endif   
 	  select  	  tcedi010.cuno   
 	  from  	  tcedi010   
 	  where  	  tcedi010._index2  =  {:tccom010.cuno}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  var.tccom100.edyn  =  tcyesno.yes   
 	  selectempty   
 	   	  var.tccom100.edyn  =  tcyesno.no   
 	  endselect   
 	  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   
 	  if (tccom010.comp  <>  0) then   
 	   	  if get.enterprise.unit(tccom010.comp,hold.cmpnr, o.mess) then   
 	   	   	  var.tccom110.cofc  =  ""   
 	   	  else   
 	   	   	  var.tccom110.cofc  =  bcstc018.sofd   
 	   	  endif   
 	  else   
 	   	  var.tccom110.cofc  =  ""   
 	  endif   
 	  if isspace(var.tccom100.prbp) or 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   
 	  var.tccom112.cvyn  =  get.tax.flag.via.bp(tccom010.cuno, bcstc.orgn.cuno,   
 	   	   	  o.mess)   
 	  if isspace(tccom010.pctf) then   
 	   	  var.tccom112.pfbp  =  ""   
 	  else   
 	   	  if get.business.partner(tccom010.pctf,bcstc.orgn.cuno, o.mess) then   
 	   	   	  var.tccom112.pfbp  =  ""   
 	   	  else   
 	   	   	  var.tccom112.pfbp  =  bcstc008.bpid   
 	   	  endif   
 	  endif   
 	  dump 4 |# tccom112   
 	  dump 5 |# tccom114   
 	  add.business.partner.to.list(var.tccom100.bpid)
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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   
 	  |   *  One  -  Time BP should not get a Parent BP filled.   
 	   	  var.tccom100.prbp  =  ""   
 	  else   
 	   	  var.tccom100.prbp  =  hold.tccom100.prbp   
 	  endif   
 	  if tccom020.inrl  =  empty then   
 	   	  var.tccom100.inrl  =  tcyesno.no   
 	  else   
 	   	  var.tccom100.inrl  =  tccom020.inrl   
 	  endif   
 	  if get.addresses("tccom020", tccom020.suno, o.mess) then   
 	   	  var.tccom020.cadr  =  ""   
 	  else   
 	   	  var.tccom020.cadr  =  bcstc004.cadr   
 	  endif   
 	  var.tccom120.cadr  =  var.tccom020.cadr   
 	  if (not isspace(tccom020.ccor)) then   
 	   	  temp.key.ccor(1;6)  =  tccom020.suno   
 	   	  temp.key.ccor(7;9)  =  tccom020.ccor   
 	   	  if not get.addresses("tccom022", temp.key.ccor, o.mess) then   
 	   	   	  |   *  no error   
 	   	   	  var.tccom120.cadr  =  bcstc004.cadr   
 	   	  endif   
 	  endif   
 	  select  	  tcedi010.*     
 	  from  	  tcedi010   
 	  where  	  tcedi010._index3  =  {:tccom020.suno}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  var.tccom100.edyn  =  tcyesno.yes   
 	  selectempty   
 	   	  var.tccom100.edyn  =  tcyesno.no   
 	  endselect   
 	  if (not isspace(tccom020.refs)) then   
 	   	  if get.cross.reference.for.contact.code("tccom020a",tccom020.suno, o.mess) then   
 	   	   	  var.tccom120.ccnt  =  ""   
 	   	  else   
 	   	   	  var.tccom120.ccnt  =  bcstc005.ccnt   
 	   	  endif   
 	  else   
 	   	  var.tccom120.ccnt  =  ""   
 	  endif   
 	  hold.ccnt  =  ""   
 	  if (not isspace(tccom020.refa)) then   
 	   	  if get.cross.reference.for.contact.code("tccom020",tccom020.suno, o.mess) then   
 	   	   	  hold.ccnt  =  ""   
 	   	  else   
 	   	   	  hold.ccnt  =  bcstc005.ccnt   
 	   	  endif   
 	  endif   
 	  if isspace(tccom020.pstx) then   
 	   	  var.tccom100.bptx  =  ""   
 	  else   
 	   	  var.tccom100.bptx  =  get.business.partner.code(tccom020.pstx, bcstc.orgn.suno, o.mess)   
 	  endif   
 	  if isspace(tccom020.scus) then   
 	   	  var.tccom120.scus  =  ""   
 	  else   
 	   	  if get.business.partner(tccom020.scus, bcstc.orgn.suno, o.mess) then   
 	   	   	  var.tccom120.scus  =  ""   
 	   	  else   
 	   	   	  var.tccom120.scus  =  bcstc008.bpid   
 	   	  endif   
 	  endif   
 	  on case tccom020.sust   
 	  case tcsust.fix:   
 	   	  var.tccom100.bpst  =  2   
 	   	  var.tccom120.bpst  =  2   
 	   	  var.tccom121.bpst  =  1   
 	   	  var.tccom122.bpst  =  1   
 	   	  var.tccom124.bpst  =  1   
 	   	  break   
 	  case tcsust.temporary:   
 	   	  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   
 	  endif   
 	  if (tccom020.comp  <>  0) then   
 	   	  if get.enterprise.unit(tccom020.comp, hold.cmpnr, o.mess) then   
 	   	   	  var.tccom120.cofc  =  ""   
 	   	  else   
 	   	   	  var.tccom120.cofc  =  bcstc018.pofd   
 	   	  endif   
 	  else   
 	   	  var.tccom120.cofc  =  ""   
 	  endif   
 	  link.to.sub  =  2   
 	  select tirou001.*     
 	  from  	  tirou001   
 	  where tirou001._index4  =  {:tccom020.suno}   
 	  as set with 1 rows   
 	  selectdo   
 	   	  link.to.sub  =  1   
 	   	  if get.enterprise.unit(tirou001.ncmp, hold.cmpnr, o.mess) then   
 	   	   	  var.tccom120.cofc  =  ""   
 	   	  else   
 	   	   	  var.tccom120.cofc  =  bcstc018.pofd   
 	   	  endif   
 	  endselect   
 	  dump 7 |# tccom120   
 	  dump 8 |# tccom121   
 	  if (link.to.sub  =  1) then   
 	   	  var.tccom122.ccnt(1;9)  =  ""   
 	  else   
 	   	  var.tccom122.ccnt(1;9)  =  hold.ccnt   
 	  endif   
 	  if tccom020.subc  =  empty then   
 	   	  tccom020.subc  =  tcyesno.no   
 	  endif   
 	  var.tccom122.cvyn  =  get.tax.flag.via.bp(tccom020.suno, bcstc.orgn.suno,   
 	   	   	  o.mess)   
 	  get.mstm.docm()   
 	  if not isspace(tccom020.cfcc) then   
 	   	  |   *  Create a cuno from cfcc, just like done in bcstc008  	   	   	   	  |# 1431629.sn   
 	   	  converted.cuno  =  bcint.dll0000.convert.factoring.code.for.bcstc008(tccom020.cfcc)  	  |# 1431629.en   
 |  	   	  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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   
 	  else   
 	   	  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   
 	   	  |   *  One  -  Time BP should not get a Parent BP filled.   
 	   	   	  var.tccom100.prbp  =  ""   
 	   	  else   
 	   	   	  var.tccom100.prbp  =  hold.tccom100.prbp   
 	   	  endif   
 	  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   
 	  dump 12  	  |# Tccom124
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:115
:SCPAC:tc
:SCMOD:com
:SFLNO:015
:ICOD:D
:QURY:START
if get.business.partner(tccom015.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 var.tccom115.pfbp =  ""              
 	 else  
 	 	 var.tccom115.pfbp =  bcstc008.bpid  
 	 endif  
 	 if get.bank.code("tccom015", tccom015.cuno &  tccom015.cban, o.mess) then  
 	 	 var.tccom115.brch =  ""            
 	 else  
 	 	 var.tccom115.brch =  bcstf006.bank  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:115
:SCPAC:tc
:SCMOD:com
:SFLNO:015
:ICOD:S
:QURY:START
select tccom015.*
from tccom015
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:com
:SFLNO:025
:ICOD:D
:QURY:START
if get.business.partner(tccom025.suno,bcstc.orgn.suno, o.mess) then  
 	 	 var.tccom125.ptbp =  ""                                                      
 	 else  
 	 	 var.tccom125.ptbp =  bcstc008.bpid  
 	 endif  
 	 if get.bank.code("tccom025", tccom025.suno &  tccom025.cban, o.mess) then  
 	 	 var.tccom125.brch =  ""                                                            
 	 else  
 	 	 var.tccom125.brch =  bcstf006.bank  
 	 endif  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:com
:SFLNO:025
:ICOD:S
:QURY:START
select tccom025.*
from tccom025
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:mcs
:SFLNO:026
:ICOD:D
:QURY:START
| *  Factoring Company will be placed in a temp variable, based on the  
 	 | *  tccuno domain as used in table bcstc008.  
 	 tmp.cfcc(1;6) =  " "  
 	 tmp.cfcc(4;3) =  tcmcs026.cfcc  
 	 if get.business.partner(tmp.cfcc,bcstc.orgn.fcomp, o.mess) then  
 	 	 var.tccom125.ptbp =  ""                                                      
 	 else  
 	 	 var.tccom125.ptbp =  bcstc008.bpid  
 	 endif  
 	 if get.bank.code("tcmcs026", tcmcs026.cfcc &  tcmcs026.cban, o.mess) then  
 	 	 var.tccom125.brch =  ""                                                            
 	 else  
 	 	 var.tccom125.brch =  bcstf006.bank  
 	 endif  
 	 dump 2
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:com
:TFLNO:125
:SCPAC:tc
:SCMOD:mcs
:SFLNO:026
:ICOD:S
:QURY:START
select tcmcs026.*
from tcmcs026
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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   
 	    	  var.tccom130.dsca  =  bcstc031.dsca  	    	    	   | # 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   
 |   	    	  dump3 |   *  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:002
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:D
:QURY:START
	   	   	   	   	   	   	   	   |  # 1151951.so  
 |   	  Field icur from the source can be mapped with iccc at the target side.  	   	   	   	   	   	   	   	   
 |   	  if (tcmcs002.ccur  <>  tcmcs002.icur) and (tcmcs002.icur  <>  empty.string(1;3) ) then   
 |   	    	  var.tcmcs002.ccur  =  tcmcs002.icur   
 |   	  else   
 |   	    	  var.tcmcs002.ccur  =  tcmcs002.ccur   
 |   	  endif   
 	   	   	   	   	   	   	   	   |  # 1151951.eo  
 	  Dump 1
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:002
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:010
:SCPAC:tc
:SCMOD:mcs
:SFLNO:010
:ICOD:D
:QURY:START
if var.tcmcs010.meec  =  empty then   
 	   	  var.tcmcs010.meec  =  tcyesno.no   
 	  else   
 	   	  var.tcmcs010.meec  =  tcmcs010.meec   
 	  endif   
 	  var.tcmcs010.ppcd  =  0   
 	  if tracs020.ppcd  <>  0 then   
 	   	  var.tcmcs010.ppcd  =  tracs020.ppcd   
 	  endif   
 	  if not read.address.formats(tcmcs010.ccty, dummy.err.mess) then   
 	   	  var.tcmcs010.coaf  =  bcstc014.coaf   
 	  else   
 	   	  var.tcmcs010.coaf  =  empty()   
 	  endif   
 	  if not get.time.zone.per.country(tcmcs010.ccty, dummy.err.mess) then   
 	   	  var.tcmcs010.tzid  =  bcstc026.tzid   
 	  else   
 	   	  var.tcmcs010.tzid  =  empty()   
 	  endif   
 	  Dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:010
:SCPAC:tc
:SCMOD:mcs
:SFLNO:010
:ICOD:S
:QURY:START
select  	  tcmcs010.*  , tracs020.ppcd   
from 	  tcmcs010, tracs020
where 	  tcmcs010.ccty refers to tracs020 unref clearunref
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tc
:TCMOD:mcs
:TFLNO:010
:SCPAC:tc
:SCMOD:mcs
:SFLNO:010
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:D
:QURY:START
	 if hold.financial.bpg  <>  tfacp005.fisu then   
 	  	 add.defaults.new.type.of.transactions()   
 	  	 hold.financial.bpg  =  tfacp005.fisu   
 	 endif 	  	    
 	 if tfacp005.tran  =  tfacp.tran.control then   
 	  	 if not isspace(tfacp005.leac) then   
 	  	 |  *  In BaanIV the control account can be left empty. These records   
 	  	 |  *  must not be migrated because they result in a fatal error after   
 	  	 |  *  migration.   
 	  	  	 dump 1   
 	  	 endif   
 	 else   
 	  	 convert.kind.of.transaction(   
 	  	  	 tfacp005.tran,   
 	  	  	 var.tfacp005.tran)   
 	  	 dump 2   
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:S
:QURY:START
select 	 tfacp005.*     
from 	 tfacp005
order by tfacp005._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:103
:SCPAC:tf
:SCMOD:acp
:SFLNO:151
:ICOD:D
:QURY:START
	  
 	 var.ttyp =  tfacp151.ttyp  
 	 var.ninv =  tfacp151.ninv  
 	 var.cbtn =  tfacp151.bpay  
 	 if not get.business.partner(tfacp151.suno,bcstc.orgn.suno,var.err.mess) then  
 	 	 var.str.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.str.bpid =  ""                                                                                                                                                                                                                                            
 	 endif  
 	 	 | *  Dump records from tfacp151  
 	 if prev.suno =  tfacp151.suno and  
 	 	 prev.line =  tfacp151.line then  
 	 	 continue  
 	 else  
 	 	 prev.suno =  tfacp151.suno  
 	 	 prev.line =  tfacp151.line  
 	 	 select 	 alstfacp151.srno  
 	 	 from 	 tfacp151 alstfacp151  
 	 	 where 	 alstfacp151._index1 =  {:tfacp151.suno,  
 	 	 	 	 :tfacp151.line}  
 	 	 order by 	 alstfacp151.srno  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if tfacp151.stib =  tfacp.stib.posted 	 then  
 	 	 	 	 var.rcrr =  1 	 | *  tcyesno.yes  
 	 	 	 	 var.crdt =  utc(tfacp151.docd,0,2)  
 | 	 	 	 	 var.cyer =  utc(tfacp151.docd,0,2) 	 |binda.o  
 	 	 	 	 var.cbtn =  tfacp151.bpay  
 	 	 	 	 var.ctyp =  tfacp151.ttyp  
 	 	 	 	 var.cdoc =  tfacp151.ninv  
 	 	 	 else  
 	 	 	 	 var.rcrr =  2 	 | *  tcyesno.no  
 	 	 	 	 var.crdt =  default.date  
 | 	 	 	 	 var.cyer =  default.date 	 	 |binda.o  
 	 	 	 	 var.cbtn =  0  
 	 	 	 	 var.ctyp =  empty.string(1;3)  
 	 	 	 	 var.cdoc =  0  
 	 	 	 endif  
 	 	 	 if itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.financial,  
 	 	 	 	 	 	 tfacp151.docd) then  
 	 	 	 	 var.nyer =  igld0012.year  
 	 	 	 	 var.fprd =  igld0012.prno  
 	 	 	 endif  
 	 	 	 if itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.reporting,  
 	 	 	 	 	 	 tfacp151.docd) then  
 	 	 	 	 var.ryer =  igld0012.year  
 	 	 	 	 var.rprd =  igld0012.prno  
 	 	 	 endif  
 	 	 	 if itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.vat,  
 	 	 	 	 	 	 tfacp151.docd) then  
 	 	 	 	 var.tyer =  igld0012.year  
 	 	 	 	 var.tprd =  igld0012.prno  
 	 	 	 endif  
 	 	 	 dump 103  
 	 	 endselect  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:103
:SCPAC:tf
:SCMOD:acp
:SFLNO:151
:ICOD:S
:QURY:START
select 	 tfacp151.*
from 	 tfacp151
where 	 tfacp151.stib =  tfacp.stib.posted
order by tfacp151.suno,tfacp151.line
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:103
:SCPAC:tf
:SCMOD:acp
:SFLNO:151
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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   
 	  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:311
:SCPAC:tf
:SCMOD:acp
:SFLNO:311
:ICOD:D
:QURY:START
	 on case tfacp311.stmf  
 	 case tfacp.remf.supl.address:  
 	 	 var.tfacp311.stmf =  1  
 	 	 break  
 	 case tfacp.remf.supl.post:  
 	 	 var.tfacp311.stmf =  1  
 	 	 break  
 	 case tfacp.remf.invo.post:  
 	 	 var.tfacp311.stmf =  3  
 	 	 break  
 	 endcase  
 	 on case tfacp311.stms  
 	 	 case tfacp.rems.supl.address:  
 	 	 var.tfacp311.stms =  1  
 	 	 break  
 	 	 case tfacp.rems.supl.post:  
 	 	 var.tfacp311.stms =  1  
 	 	 break  
 	 	 case tfacp.rems.invo.post:  
 	 	 var.tfacp311.stms =  3  
 	 	 break  
 	 	 case tfacp.rems.no:  
 	 	 var.tfacp311.stms =  4  
 	 	 break  
 	 endcase  
 	 on case tfacp311.frqt  
 	 	 case tfacr.frqt.days:  
 	 	 	 var.tfacp311.frqt =  1 	  
 	 	 case tfacr.frqt.weeks:  
 	 	 	 var.tfacp311.frqt =  2  
 	 	 case tfacr.frqt.months:  
 	 	 	 var.tfacp311.frqt =  3  
 	 endcase  
 	 dump 311
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:311
:SCPAC:tf
:SCMOD:acp
:SFLNO:311
:ICOD:S
:QURY:START
select tfacp311.*
from tfacp311
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:311
:SCPAC:tf
:SCMOD:acp
:SFLNO:311
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:312
:SCPAC:tf
:SCMOD:acp
:SFLNO:312
:ICOD:D
:QURY:START
	 dump 312
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:312
:SCPAC:tf
:SCMOD:acp
:SFLNO:312
:ICOD:S
:QURY:START
select tfacp312
from tfacp312
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:312
:SCPAC:tf
:SCMOD:acp
:SFLNO:312
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:313
:SCPAC:tf
:SCMOD:acp
:SFLNO:313
:ICOD:D
:QURY:START
	 dump 313
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:313
:SCPAC:tf
:SCMOD:acp
:SFLNO:313
:ICOD:S
:QURY:START
select tfacp313.*
from tfacp313
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:313
:SCPAC:tf
:SCMOD:acp
:SFLNO:313
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:314
:SCPAC:tf
:SCMOD:acp
:SFLNO:314
:ICOD:D
:QURY:START
	 dump 314
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:314
:SCPAC:tf
:SCMOD:acp
:SFLNO:314
:ICOD:S
:QURY:START
select tfacp314.*
from tfacp314
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:314
:SCPAC:tf
:SCMOD:acp
:SFLNO:314
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:315
:SCPAC:tf
:SCMOD:acp
:SFLNO:315
:ICOD:D
:QURY:START
	 dump 315
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:315
:SCPAC:tf
:SCMOD:acp
:SFLNO:315
:ICOD:S
:QURY:START
select tfacp315.*
from tfacp315
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:315
:SCPAC:tf
:SCMOD:acp
:SFLNO:315
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:460
:SCPAC:tf
:SCMOD:acp
:SFLNO:260
:ICOD:D
:QURY:START
	 on case tfacp260.frst  
 	 	 case tfacp.remf.supl.address :  
 	 	 var.tfacp460.frst =  1  
 	 	 break  
 	 	 case tfacp.remf.supl.post :  
 	 	 var.tfacp460.frst =  1  
 	 	 break  
 	 	 case tfacp.remf.invo.post :  
 	 	 var.tfacp460.frst =  3  
 	 	 break  
 	 endcase  
 	  
 	 on case tfacp260.secd  
 	 	 case tfacp.rems.supl.address :  
 	 	 var.tfacp460.secd =  1  
 	 	 break  
 	 	 case tfacp.rems.supl.post :  
 	 	 var.tfacp460.secd =  1  
 	 	 break  
 	 	 case tfacp.rems.invo.post :  
 	 	 var.tfacp460.secd =  3  
 	 	 break  
 	 	 case tfacp.rems.no:  
 	 	 var.tfacp460.secd =  4  
 	 	 break  
 	 endcase  
 	 dump 460
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:460
:SCPAC:tf
:SCMOD:acp
:SFLNO:260
:ICOD:S
:QURY:START
select tfacp260.*
from tfacp260
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:460
:SCPAC:tf
:SCMOD:acp
:SFLNO:260
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:461
:SCPAC:tf
:SCMOD:acp
:SFLNO:261
:ICOD:D
:QURY:START
	 dump 461
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:461
:SCPAC:tf
:SCMOD:acp
:SFLNO:261
:ICOD:S
:QURY:START
select tfacp261.*
from tfacp261
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acp
:TFLNO:461
:SCPAC:tf
:SCMOD:acp
:SFLNO:261
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:103
:SCPAC:tf
:SCMOD:acr
:SFLNO:151
:ICOD:D
:QURY:START
	 var.ttyp =  tfacr151.ttyp  
 	 var.ninv =  tfacr151.ninv  
 	  
 	 if not get.business.partner(tfacr151.cuno,bcstc.orgn.cuno,var.err.mess) then  
 	 	 var.str.bpid =  bcstc008.bpid  
 	 else  
 	 	 var.str.bpid =  ""                                                                                                                                                                                              
 	 endif  
 	 | *  Dump records from tfacr151  
 	 if prev.suno =  tfacr151.cuno and  
 	 	 prev.line =  tfacr151.line then  
 	 	 continue  
 	 else  
 	 	 prev.suno =  tfacr151.cuno  
 	 	 prev.line =  tfacr151.line  
 	 	 select 	 a.srno  
 	 	 from 	 tfacr151 a  
 	 	 where 	 a._index1 =  {:tfacr151.cuno,  
 	 	 	 	 :tfacr151.line}  
 	 	 order by 	 a.srno  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if tfacr151.stib =  tfacp.stib.posted 	 then  
 	 	 	 	 var.rcrr =  1 	 | *  tcyesno.yes  
 	 	 	 	 var.crdt =  utc(tfacr151.docd,0,2)  
 | 	 	 	 	 var.cyer =  utc(tfacr151.docd,0,2) 	 |binda.o  
 	 	 	 	 var.cbtn =  tfacr151.bpay  
 	 	 	 	 var.ctyp =  tfacr151.ttyp  
 	 	 	 	 var.cdoc =  tfacr151.ninv  
 	 	 	 else  
 	 	 	 	 var.rcrr =  2 	 | *  tcyesno.no  
 	 	 	 	 var.crdt =  default.date  
 | 	 	 	 	 var.cyer =  default.date 	 	 |binda.o  
 	 	 	 	 var.cbtn =  0  
 	 	 	 	 var.ctyp =  empty.string(1;3)  
 	 	 	 	 var.cdoc =  0  
 	 	 	 endif  
 	 	 	 if itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.financial,  
 	 	 	 	 	 	 tfacr151.docd) then  
 	 	 	 	 var.nyer =  igld0012.year  
 	 	 	 	 var.fprd =  igld0012.prno  
 	 	 	 endif  
 	 	 	 if itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.reporting,  
 	 	 	 	 	 	 tfacr151.docd) then  
 	 	 	 	 var.ryer =  igld0012.year  
 	 	 	 	 var.rprd =  igld0012.prno  
 	 	 	 endif  
 	 	 	 if itfgld0012.get.year.prno.from.date( get.compnr(),  
 	 	 	 	 	 	 tfgld.ptyp.vat,  
 	 	 	 	 	 	 tfacr151.docd) then  
 	 	 	 	 var.tyer =  igld0012.year  
 	 	 	 	 var.tprd =  igld0012.prno  
 	 	 	 endif  
 	  
 	 	 	 dump 103  
 	 	 endselect  
 	 endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:103
:SCPAC:tf
:SCMOD:acr
:SFLNO:151
:ICOD:S
:QURY:START
select 	 tfacr151.*
from 	 tfacr151
where 	 tfacr151.stib =  tfacp.stib.posted
order by tfacr151.cuno,tfacr151.line
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:acr
:TFLNO:103
:SCPAC:tf
:SCMOD:acr
:SFLNO:151
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:002
:SCPAC:tf
:SCMOD:cmg
:SFLNO:002
:ICOD:D
:QURY:START
	   select tfcmg116.reas   
 	   from tfcmg116   
 	   where tfcmg116.reas  =  :tfcmg002.reas   
 	   selectdo   
 	     	   var.tfcmg002.vldc  =  1   
 	   selectempty   
 	     	   var.tfcmg002.vldc  =  2   
 	   endselect   
 	   fill.serv()   	     	     	     	     	    |  FBU.n   
 	     	     
 	   dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:002
:SCPAC:tf
:SCMOD:cmg
:SFLNO:002
:ICOD:S
:QURY:START
select tfcmg002.*
from tfcmg002
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:002
:SCPAC:tf
:SCMOD:cmg
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:003
:SCPAC:tf
:SCMOD:cmg
:SFLNO:003
:ICOD:D
:QURY:START
var.tfcmg003.rgrp  =  0   	      	      	      	      	      	      	     |    #  200  -  95855.sn   
 var.tfcmg003.rgr2  =  0   	      	      	      	      	      	     |    #  200  -  95855.en   
 	      	      	      	      	      	      	      	     |    #  FBU.sn   
 on case tfcmg003.ddmt   
 	   case tfcmg.ddmt.mandate:   
 	      	   var.tfcmg003.proc  =  1   
 	      	   break   
 	   case tfcmg.ddmt.preauthorized:   
 	      	   var.tfcmg003.proc  =  2   
 	      	   break   
 	   default:   
 	      	   var.tfcmg003.proc  =  3   
 endcase   
 	      	      	      	      	      	      	      	      
 on case tfcmg003.auto   
 	   case tcyesno.yes:   
 	      	   var.tfcmg003.auto  =  1   
 	      	   break   
 	   case tcyesno.no:   
 	      	   var.tfcmg003.auto  =  2   
 	      	   break   
 endcase   
 	      	      	      	      	      	      	      	      
 	      	      	      	      	      	      	      	     |    #  FBU.en   
 	   if etol(tfcmg003.copt)  =  0 then   
 	      	   var.tfcmg003.copt  =  4   
 	   else   
 	      	   var.tfcmg003.copt  =  etol(tfcmg003.copt)   
 	   endif   
 	   if etol(tfcmg003.cact)  =  0 then   
 	      	   var.tfcmg003.cact  =  4   
 	   else   
 	      	   var.tfcmg003.cact  =  etol(tfcmg003.cact)   
 	   endif   
 	   if etol(tfcmg003.dnum)  =  0 then   
 	      	   var.tfcmg003.dnum  =  4   
 	   else   
 	      	   var.tfcmg003.dnum  =  etol(tfcmg003.dnum)   
 	   endif   
 	   if etol(tfcmg003.typp)  =  0 then   
 	      	   var.tfcmg003.typp  =  3   
 	   else   
 	      	   var.tfcmg003.typp  =  etol(tfcmg003.typp)   
 	   endif   
 	   if etol(tfcmg003.odv1)  =  0 then   
 	      	   var.tfcmg003.odv1  =  2   
 	   else   
 	      	   var.tfcmg003.odv1  =  etol(tfcmg003.odv1)   
 	   endif   
 	   if etol(tfcmg003.bodd)  =  0 then   
 	      	   var.tfcmg003.bodd  =  2   
 	   else   
 	      	   var.tfcmg003.bodd  =  etol(tfcmg003.bodd)   
 	   endif   
 	   if etol(tfcmg003.uiba)  =  0 then   
 	      	   var.tfcmg003.uiba  =  2   
 	   else   
 	      	   var.tfcmg003.uiba  =  etol(tfcmg003.uiba)   
 	   endif   
 on case strip$ (tfcmg003.sess)   
 	   case   	   "tfcmg1260s000" :        
 	      	      	      	   var.tfcmg003.sess  =  get.string(18)   
 	      	      	      	   break   
 |     	   case   	   "tfcmg2113s000" :      	      |    #    200  -    95852.so      
 |     	      	      	      	   var.tfcmg003.sess  =  get.string(19)   
 |     	      	      	      	   break   
 |     	   case   	   "tfcmg2112s000" :        
 |     	      	      	      	   var.tfcmg003.sess  =  get.string(20)   
 |     	      	      	      	   break   	      	      	      	      	     |    #  200  -  95852.eo   
 	   case "tfcmg4260s000" :     	          	          	          	          	            
 	      	      	      	   var.tfcmg003.sess  =  get.string(43)   
 	      	      	      	   break   
 	   default :   
 	      	      	   if isspace (tfcmg003.sess) then   	      	      
 	      	      	      	   var.tfcmg003.sess  =  empty.string(1;20)   
 	      	      	   endif   	      
 	      	      	   break   	      	      	      	      	      	      
 	   endcase   
 	   if tfcmg003.repa  =  tfcmg.repa.payment and tfcmg003.auto  =  tcyesno.yes then  |    #  200  -  97665.n   
 	   if tfcmg003.rgrp  =  5 then   	      	      	      	     |    #  200  -  95855.sn   
 	      	   var.tfcmg003.rgrp  =  41   
 	   else   
 	      	   if tfcmg003.rgrp  =  17 then   	      	      	      	      
 	      	      	   var.tfcmg003.rgrp  =  15   
 	      	   else   
 	      	      	   var.tfcmg003.rgrp  =  tfcmg003.rgrp   
 	      	   endif   
 |     	      	   var.tfcmg003.rgrp  =  tfcmg003.rgrp   
 	   endif   
 	   if tfcmg003.rgr2  =  5 then   	      	      	      	      
 	      	   var.tfcmg003.rgr2  =  41   
 	   else   
 	      	   if tfcmg003.rgr2  =  17 then   	      	      	      	      
 	      	      	   var.tfcmg003.rgr2  =  15   
 	      	   else   
 	      	      	   var.tfcmg003.rgr2  =  tfcmg003.rgr2   
 	      	   endif   	      	      	      	      	      	      	      
 |     	      	   var.tfcmg003.rgr2  =  tfcmg003.rgr2   
 	   endif   	      	      	      	      	      	      	      
 	      
 	     |    #  200  -  95855.en   
 	   else   
 	      	   var.tfcmg003.rgrp  =  tfcmg003.rgrp   
 	      	   var.tfcmg003.rgr2  =  tfcmg003.rgr2   
 	   endif   	      	      	      	      	      	      	     |    #  200  -  97665.n   
 	   if tfcmg003.auto  <>  tcyesno.yes then   	      	     |    #  P9.sn   
 	      	   var.tfcmg003.pfby  =  255   
 	   else   
 	      	   var.tfcmg003.pfby  =  10   
 	   endif   	      	      	      	      	      	     |    #  FP9.en   
 	      	      	      	      	      	      	      	     |    #  FP11.sn   
 	   if (var.tfcmg003.rgrp  =  69 or var.tfcmg003.rgrp  =  70 or   
 	    var.tfcmg003.rgr2  =  69 or var.tfcmg003.rgr2  =  70) then   
 	      	   var.tfcmg003.hash  =  target(tchash.sha)   
 	   else   
 	      	   var.tfcmg003.hash  =  target(tchash.na)   
 	   endif   	      	      	      	      
 	      	      	      	      	      	      	      	     |    #  FP11.en   
 	   select tfcmg007.*     	      
 	   from tfcmg007   
 	   where tfcmg007._index2  =  {:tfcmg003.paym}   
 	   as set with 1 rows   
 	   selectdo   
 	      	   var.tfcmg003.poda  =  1   
 	   selectempty   
 	      	   var.tfcmg003.poda  =  2   
 	   endselect   	      
 	   dump 1  |    *  Payment  /  Receipt Method
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:003
:SCPAC:tf
:SCMOD:cmg
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:103
:SCPAC:tf
:SCMOD:cmg
:SFLNO:103
:ICOD:D
:QURY:START
if get.business.partner(tfcmg103.suno,bcstc.orgn.suno,err.mess) then  
 	 var.tfcmg103.ptbp =  ""                              
 else  
 	 var.tfcmg103.ptbp =  bcstc008.bpid  
 	  
 endif  
 | ALL THE BELOW FIELDS ARE MANDATORY IN TARGET AND NOT IN SOURCE  
 if etol(tfcmg103.blac) =  0 then  
 	 var.tfcmg103.blac =  4  
 else  
 	 var.tfcmg103.blac =  etol(tfcmg103.blac)  
 endif  
 if etol(tfcmg103.comp) =  0 then  
 	 var.tfcmg103.comp =  2  
 else  
 	 var.tfcmg103.comp =  etol(tfcmg103.comp)  
 endif  
 if etol(tfcmg103.paid) =  0 then  
 	 var.tfcmg103.paid =  2  
 else  
 	 var.tfcmg103.paid =  etol(tfcmg103.paid)  
 endif  
 if etol(tfcmg103.rlet) =  0 then  
 	 var.tfcmg103.rlet =  2  
 else  
 	 var.tfcmg103.rlet =  etol(tfcmg103.rlet)  
 endif  
 if etol(tfcmg103.post) =  0 then  
 	 var.tfcmg103.post =  2  
 else  
 	 var.tfcmg103.post =  etol(tfcmg103.post)  
 endif  
 dump 1 	 | *  tfcmg103 -  Composed Payments
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:103
:SCPAC:tf
:SCMOD:cmg
:SFLNO:103
:ICOD:S
:QURY:START
select tfcmg103.*
from tfcmg103
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:103
:SCPAC:tf
:SCMOD:cmg
:SFLNO:103
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:104
:SCPAC:tf
:SCMOD:cmg
:SFLNO:104
:ICOD:D
:QURY:START
	  new.country  =  ""    
 	  new.tax  =  ""    
 	  get.tax.by.country.code(tfcmg104.vatc, tfcmg104.cvat, new.country,   
 	   	   	  new.tax, err.mess)   
 if (tfcmg104.spot  =  tcyesno.yes) then   
 	   	  var.tfcmg104.rade  =  1   
 else   
 |  	   	  if (tfcmg104.spot  =  tcyesno.no) then   
 	   	   	  var.tfcmg104.rade  =  6   
 |  	   	  endif   
 endif   
 |  	  if tfcmg104.rate  =  0 then  	   	   	   	   	  |# ravi.so   
 |  	   	  tfcmg104.rate  =  1.0   
 |  	  endif  	   	   	   	   	   	   	   	  |# ravi.eo   
 |  	  var.str.bpid  =  get.bpid (tfcmg104.suno,bccom.orgn.suno)   
 	  if get.business.partner(tfcmg104.suno,bcstc.orgn.suno,err.mess) then   
 	  var.tfcmg104.bpid  =  ""    
 	  else   
 	  var.tfcmg104.bpid  =  bcstc008.bpid   
 	  endif   
 	  if (tfcmg104.unip  =  tcyesno.yes) then   
 	   	   	  var.str.rdat  =  utc (tfcmg104.pdat,0)   
 	  else   
 	   	   	  select  	  tfcmg105.pdat,tfcmg105.suno,tfcmg105.orno   
 	   	   	  from  	  tfcmg105   
 	   	   	  where  	  tfcmg105._index1  =  {:tfcmg104.suno, :tfcmg104.orno}   
 	   	   	  order by tfcmg105.suno,tfcmg105.orno   
 	   	   	  as set with 1 rows   
 	   	   	  selectdo   
 	   	   	   	  var.str.rdat  =  utc (tfcmg105.pdat,0)   
 	   	   	  endselect   
 	  endif   
 	  if etol(tfcmg104.post)  =  1 then  	   	   	   	   	  |# ravi.sn   
 	   	  var.tfcmg104.adty  =  1   
 	   	  fill.adty()  	   	   	   	   	  | FBU.n   
 	  else   
 	   	  var.tfcmg104.adty  =  0   
 	  endif  	   	   	   	   	   	   	   	  |# ravi.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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:111
:SCPAC:tf
:SCMOD:cmg
:SFLNO:111
:ICOD:D
:QURY:START
	  new.country  =  ""               
 	  new.tax  =  ""               
 	  get.tax.by.country.code(tfcmg111.vatc, tfcmg111.cvat, new.country,   
 	    	    	  new.tax, err.mess)   
 var.tfcmg111.adty  =  0  	    	    	    	    	    	   | # ravi.n   
 var.str.rdin  =  utc.default  	    	    	    	    	   | # 200  -  97654  -  1.n   
 on case tfcmg111.tant   
 	  case tfcmg.tant.invoice :   
 	    	  if not isspace (tfcmg111.cuno) then   
 	    	    	  get.rate.date.and.rate.type.acr.record()   
 	    	  else   
 	    	    	  if not isspace (tfcmg111.suno) then   
 	    	    	    	  get.rate.date.and.rate.type.acp.record()   
 	    	    	  endif   
 	    	  endif   
 	    	  break   
 	  case tfcmg.tant.purchase.inv :   
 	    	  get.rate.date.and.rate.type.acp.record()   
 	    	  break   
 	  case tfcmg.tant.sales.inv :   
 	    	  get.rate.date.and.rate.type.acr.record()   
 	    	  break   
 	  case tfcmg.tant.advance :   
 	    	  if not isspace(tfcmg111.suno) then  	    	    	    	     
 	    	    	  var.tfcmg111.adty  =  1   
 	    	    	  fill.adty()  	    	    	   | FBU.n   
 	    	  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:130
:SCPAC:tf
:SCMOD:cmg
:SFLNO:001
:ICOD:D
:QURY:START
	  
 	 select tfcmg101.btno, tfcmg101.suno, tfcmg101.comp, tfcmg101.reas, tfcmg101.bank, tfcmg117.*   
 	 from tfcmg101, tfcmg117,tfcmg001  
 	 where tfcmg101.bank =  :tfcmg001.bank  
 	 and tfcmg101.btno =  tfcmg117.btno  
 	 and tfcmg101.suno =  tfcmg117.suno  
 	 and tfcmg101.comp =  tfcmg117.comp  
 	 and tfcmg101.reas =  tfcmg117.reas  
 	 as set with 1 rows  
 	 selectdo 	  
 	 	  
 	 	 var.tfcmg130.sequ =  var.tfcmg130.sequ +  1  
 	 	 on case tfcmg117.cost  
 	 	 case tfcmg.cost.cost.00:  
 	 	 	 var.coal =  1  
 	 	 	 break  
 	 	 case tfcmg.cost.cost.01:  
 	 	 	 var.coal =  2  
 	 	 	 break  
 	 	 case tfcmg.cost.cost.02:  
 	 	 	 var.coal =  3  
 	 	 	 break  
 	 	 default:  
 	 	 	 var.coal =  1  
 	 	 endcase  
 	 	 	 	 	 	 	 | #  148935.so  
 | 	 	 select 	 tfcmg001.buba  
 | 	 	 from 	 tfcmg001  
 | 	 	 where 	 tfcmg001.bank =  :tfcmg101.bank  
 | 	 	 as set with 1 rows  
 | 	 	 selectdo  
 | 	 	 	 var.oadt =  etol(tfcmg001.buba)  
 | 	 	 endselect  
 	 	 	 	 	 	 	 | #  148935.eo  
 	 	 dump 130  
 	 endselect
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:130
:SCPAC:tf
:SCMOD:cmg
:SFLNO:001
:ICOD:S
:QURY:START
select tfcmg001.*
from tfcmg001
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:130
:SCPAC:tf
:SCMOD:cmg
:SFLNO:001
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:D
:QURY:START
	  new.country  =  ""    
 	  new.tax  =  ""    
 	  get.tax.by.country.code(tfcmg204.vatc, tfcmg204.cvat, new.country,   
 	   	   	  new.tax, err.mess)   
 	  var.tfcmg204.adty  =  0  	   	   	   	   	   	   	     
 	  var.tfcmg204.bpid (1;9)  =  " "   
 	  var.tfcmg204.pbpt (1;9)  =  " "   
 	  if isspace(tfcmg204.cuno) and isspace(tfcmg204.suno) then   
 	   	  var.tfcmg204.pbpt  =  ""    
 	  else   
 	   	  if not isspace(tfcmg204.cuno) then   
 	   	   	  if get.business.partner(tfcmg204.cuno,bcstc.orgn.cuno,err.mess) then   
 	   	   	   	  var.tfcmg204.pbpt  =  ""    
 	   	   	  else   
 	   	   	   	  var.tfcmg204.pbpt  =  bcstc008.bpid   
 	   	   	  endif   
 	   	   	  var.str.rtyp  =  var.str.sls.rtyp   
 	   	  else   
 	   	   	  if not isspace(tfcmg204.suno) then   
 	   	   	   	  if get.business.partner(tfcmg204.suno,bcstc.orgn.suno,err.mess) then   
 	   	   	   	   	  var.tfcmg204.pbpt  =  ""    
 	   	   	   	  else   
 	   	   	   	   	  var.tfcmg204.pbpt  =  bcstc008.bpid   
 	   	   	   	  endif   
 	   	   	   	  var.str.rtyp  =  var.str.pur.rtyp   
 	   	   	  endif   
 	   	  endif   
 	  endif  	   	     
 	     
 	   	   	  on case  	  tfcmg204.tran   
 	   	   	  case  	  tfcmg.tran.advance.paym :   
 	   	   	   	  var.tfcmg204.adty  =  1   
 	   	   	   	  fill.adty()  	   	   	   	   	  | FBU.n  	     
 	   	   	   	  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fst
:TFLNO:100
:SCPAC:tf
:SCMOD:fst
:SFLNO:100
:ICOD:D
:QURY:START
	  var.statement  =  get.financial.statement.code(bcfst.styp.fin.statement, tffst100.fstm)   
 	  var.only.used.for.external.reporting  =  tcyesno.yes   
 	  select  	  tffst110.fstm   
 	  from  	  tffst110   
 	  where  	  tffst110.fstm  =  :tffst100.fstm   
 	  as set with 1 rows   
 	  selectdo   
 	   	  var.only.used.for.external.reporting  =  tcyesno.no   
 	  endselect   
 	  var.description  =  get.description(tffst100.desc, var.statement)   
 	  var.user.last.modified  =  get.user.modified(tffst100.usrm, tffst100.usrc)   
 	  var.date.last.modifed  =  get.last.modified.date(tffst100.datm, tffst100.datc)   
 	  var.time.last.modifed  =  get.last.modified.time(tffst100.timm, tffst100.timc)   
 	  var.time.created.seconds  =  time.in.seconds(tffst100.timc)   
 	  var.time.last.modifed.seconds  =  time.in.seconds(var.time.last.modifed)   
 	  dump 1 |   *  Statements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fst
:TFLNO:100
:SCPAC:tf
:SCMOD:fst
:SFLNO:100
:ICOD:S
:QURY:START
select  	  tffst100.*     
from 	  tffst100
order by tffst100._index1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fst
:TFLNO:100
:SCPAC:tf
:SCMOD:fst
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fst
:TFLNO:100
:SCPAC:tf
:SCMOD:fst
:SFLNO:400
:ICOD:D
:QURY:START
	  var.statement  =  get.financial.statement.code(bcfst.styp.cons.statement, tffst400.cstm)   
 	  var.description  =  get.description(tffst400.desc, var.statement)   
 	  var.user.last.modified  =  get.user.modified(tffst400.usrm, tffst400.usrc)   
 	  var.date.last.modifed  =  get.last.modified.date(tffst400.datm, tffst400.datc)   
 	  var.time.last.modifed  =  get.last.modified.time(tffst400.timm, tffst400.timc)   
 	  var.time.created.seconds  =  time.in.seconds(tffst400.timc)   
 	  var.time.last.modifed.seconds  =  time.in.seconds(var.time.last.modifed)   
 	  dump 2  	   	  |   *  Consolidated Statements
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fst
:TFLNO:100
:SCPAC:tf
:SCMOD:fst
:SFLNO:400
:ICOD:S
:QURY:START
select  	  tffst400.*     
from 	  tffst400
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:fst
:TFLNO:100
:SCPAC:tf
:SCMOD:fst
:SFLNO:400
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:008
:SCPAC:bc
:SCMOD:stf
:SFLNO:008
:ICOD:D
:QURY:START
	  |   *  Currency Difference Contra account is added.   
 	  var.tfgld008.atyp  =  get.account.type(bcstf008.leac)   
 	   	   	   	   	   	   	   	  |# FP10.sn   
 	  var.cvr.udim1  =  ""  	     
 	  var.cvr.udim2  =  ""   
 	  var.cvr.udim3  =  ""   
 	  var.cvr.udim4  =  ""   
 	  var.cvr.udim5  =  ""   
 	   	   	   	   	   	   	   	     
 	  var.tfgld008.atyp  =  get.account.type(bcstf008.leac)   
 	  if dimension1.used  =  tcyesno.yes then  	   	     
 	   	  var.tfgld008.dim1  =  tfgld.dopt.optional   
 	   	  add.dimension.range.by.ledger.account(   
 	   	   	  bcstf008.cdca,  	   	     
 	   	   	  1,   
 	   	   	  var.cvr.udim1)  	   	   	     
 	  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.cdca,    
 	   	   	  2,   
 	   	   	  var.cvr.udim2)  	   	   	     
 	  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.cdca,  	   	   	   	     
 	   	   	  3,   
 	   	   	  var.cvr.udim3)  	   	   	     
 	  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.cdca,  	   	     
 	   	   	  4,   
 	   	   	  var.cvr.udim4)  	   	   	     
 	  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.cdca,  	   	     
 	   	   	  5,   
 	   	   	  var.cvr.udim5)  	   	   	     
 	  else  	   	   	     
 	   	  var.tfgld008.dim5  =  tfgld.dopt.no   
 	  endif  	   	   	   	   	   	     
 	   	   	   	   	   	   	   	   	     
 	  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)   
 	  dump 3
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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   
 	   	   	   	   	   	   	   	  |# 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   
 	   	  |   *  Integration Accounts   
 	  else   
 	   	  set.attributes.non.integration.account()   
 	   	  if tfgld008.icur  =  tcicur.difference then   
 	   	   	  dummy.long  =  get.curr.diff.contra.account(   
 	   	   	   	   	  tfgld008.leac,   
 	   	   	   	   	  error.mess)   
 	   	   	  var.tfgld008.cdca  =  bcstf008.cdca   
 	   	  else   
 	   	   	  var.tfgld008.cdca  =  ""    
 	   	  endif   
 	   	  dump 1 |   *  Other, non integration accounts   
 	  endif
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:D
:QURY:START
	    	    	    	    	   | # FBU.sn   
 	  if tfgld102.catg  =  tfgld.catg.cash then   
 	    	  var.tfgld102.adty  =  fill.adty.from.tfcmg294()   
 	  else   
 	    	  var.tfgld102.adty  =  fill.adty.from.tfcmg295()   
 	  endif   
 	     
 	    	    	    	    	   | # FBU.en   
 	  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   
 	  if not isspace(tfgld102.ccty) then  	    	    	   | # SP2.sn   
 	    	  var.tfgld102.ccty  =  get.country.of.financial.company(   
 	    	    	    	    	  tfgld102.cono)   
 	  endif  	    	    	    	    	    	    	   | # SP2.en   
 	  for element  =  1 to 3   
 	    	  var.tfgld102.rate(element)  =  fill.mc.field.double(   
 	    	    	    	  tfgld102.rate,   
 	    	    	    	  element,   
 	    	    	    	  0.000001)  	     
 	    	  var.tfgld102.irat(element)  =  fill.mc.field.double(   
 	    	    	    	  0.000001,   
 	    	    	    	  element,   
 	    	    	    	  0.000001)  	    	    	     
 	    	   |   *  Rate fields must always be filled.   
 	    	  var.tfgld102.fact(element)  =  fill.mc.field.long(   
 	    	    	    	  tfgld102.fact,   
 	    	    	    	  element,   
 	    	    	    	  1)  	     
 	    	  var.tfgld102.ifac(element)  =  fill.mc.field.long(   
 	    	    	    	  1,   
 	    	    	    	  element,   
 	    	    	    	  1)  	    	     
 	    	  var.tfgld102.amth(element)  =  fill.mc.field.double(   
 	    	    	    	  tfgld102.amth,   
 	    	    	    	  element,   
 	    	    	    	  0.0)  	     
 	    	  var.tfgld102.vamh(element)  =  fill.mc.field.double(   
 	    	    	    	  tfgld102.vamh,   
 	    	    	    	  element,   
 	    	    	    	  0.0)  	     
 	    	  var.tfgld102.ifac(element)  =  fill.mc.field.long(   
 	    	    	    	  1,   
 	    	    	    	  element,   
 	    	    	    	  1)   
 	  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:62
:VERS:B4cf
: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:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:106
:SCPAC:tf
:SCMOD:gld
:SFLNO:106
:ICOD:D
:QURY:START
	  var.str.bpid  =  ""      
 	  var.str.rtyp  =  var.str.eu.rtyp   
 	    	    	    	    	    	    	   | # FBU.sn   
 	  if tfgld106.catg  =  tfgld.catg.cash then   
 	    	  var.tfgld106.adty  =  fill.adty.from.tfcmg294()   
 	  else   
 	    	  var.tfgld106.adty  =  fill.adty.from.tfcmg295()   
 	  endif   
 	    	    	    	    	    	    	   | # FBU.en   
 	  if not isspace (tfgld106.cuno) then   
 	    	  var.str.bpid  =  get.business.partner.code(   
 	    	    	    	    	  tfgld106.cuno,   
 	    	    	    	    	  bcstc.orgn.cuno,   
 	    	    	    	    	  error.message)   
 	    	  var.str.rtyp  =  var.str.sls.rtyp   
 	  else   
 	    	  if not isspace (tfgld106.suno) then   
 	    	    	  var.str.bpid  =  get.business.partner.code(   
 	    	    	    	    	    	  tfgld106.suno,   
 	    	    	    	    	    	  bcstc.orgn.suno,   
 	    	    	    	    	    	  error.message)   
 	    	    	  var.str.rtyp  =  var.str.pur.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   
 |   	  ret.long  =  get.tax.by.country.code(  	    	    	   | # SP2.so   
 |   	    	    	  tfgld106.ccty,   
 |   	    	    	  tfgld106.cvat,   
 |   	    	    	  var.tfgld106.ccty,   
 |   	    	    	  var.tfgld106.cvat,   
 |   	    	    	  error.message)  	    	    	    	   | # SP2.eo   
 	  if not isspace(tfgld106.ccty) then  	    	    	   | # SP2.sn   
 	    	  var.tfgld106.ccty  =  get.country.of.financial.company(   
 	    	    	    	    	  tfgld106.ocmp)   
 	  endif  	    	    	    	    	    	    	   | # SP2.en   
 	  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:116
:SCPAC:tf
:SCMOD:gld
:SFLNO:199
:ICOD:D
:QURY:START
	 get.tax.information.from.transaction(  
 	 	 company,  
 	 	 tfgld199.otyp,  
 	 	 tfgld199.odoc,  
 	 	 tfgld199.olin,  
 	 	 tfgld199.osrl,  
 	 	 tfgld199.osrn,  
 	 	 var.tfgld116.ccty,  
 	 	 var.tfgld116.cvat)  
 	 var.tfgld116.catg =  get.category.from.transaction.type(tfgld199.otyp)  
 	 if tfgld199.recd <>  0 then  
 	 	 var.tfgld116.rmah =  str$(tfgld199.recn) &  " /" &                       
 	 	 	 	 	 num.to.date$(tfgld199.recd, 2)  
 	 else  
 	 	 var.tfgld116.rmah =  ""              
 	 endif 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:116
:SCPAC:tf
:SCMOD:gld
:SFLNO:199
:ICOD:S
:QURY:START
select 	 tfgld199.*
from 	 tfgld199
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:116
:SCPAC:tf
:SCMOD:gld
:SFLNO:199
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:117
:SCPAC:tf
:SCMOD:gld
:SFLNO:198
:ICOD:D
:QURY:START
	 var.tfgld117.desc =  "Seq. " &  tfgld198.leac &  " " &   
 	 	 	 	 str$(tfgld198.sera)  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:117
:SCPAC:tf
:SCMOD:gld
:SFLNO:198
:ICOD:S
:QURY:START
select 	 tfgld198.*
from 	 tfgld198
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:117
:SCPAC:tf
:SCMOD:gld
:SFLNO:198
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:130
:SCPAC:tf
:SCMOD:ust
:SFLNO:100
:ICOD:D
:QURY:START
	 on case tfust100.umst  
 	 case tfust.umst.ums:  
 	 	 var.tfgld130.rtyp =  target(tfgld.rtyp.revenue)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.steuer:  
 	 	 var.tfgld130.rtyp =  target(tfgld.rtyp.tax)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.ust.pos:  
 	 	 var.tfgld130.rtyp =  target(tfgld.rtyp.tax.pos)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.land:  
 	 	 var.tfgld130.rtyp =  target(tfgld.rtyp.ccty)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.saldo:  
 	 	 var.tfgld130.rtyp =  target(tfgld.rtyp.balance)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 default:  
 	 	 var.tfgld130.rtyp =  target(tfgld.rtyp.tax)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 endcase  
 	 dump 130
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:130
:SCPAC:tf
:SCMOD:ust
:SFLNO:100
:ICOD:S
:QURY:START
select tfust100.*
from tfust100
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:130
:SCPAC:tf
:SCMOD:ust
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:131
:SCPAC:tf
:SCMOD:ust
:SFLNO:106
:ICOD:D
:QURY:START
	 on case tfust106.umst  
 	 case tfust.umst.ums:  
 	 	 var.tfgld131.rtyp =  target(tfgld.rtyp.revenue)  
 	 	 break 	 	 	 	 	 | #  203051 	  
 	 case tfust.umst.steuer:  
 	 	 var.tfgld131.rtyp =  target(tfgld.rtyp.tax)  
 	 	 break 	 	 	 	 	 	 | #  203051  
 	 case tfust.umst.ust.pos:  
 	 	 var.tfgld131.rtyp =  target(tfgld.rtyp.tax.pos)  
 	 	 break 	 	 	 	 	 	 | #  203051  
 	 case tfust.umst.land:  
 	 	 var.tfgld131.rtyp =  target(tfgld.rtyp.ccty)  
 	 	 break 	 	 	 	 	 	 | #  203051  
 	 case tfust.umst.saldo:  
 	 	 var.tfgld131.rtyp =  target(tfgld.rtyp.balance)  
 	 	 break 	 	 	 	 	 	 | #  203051  
 	 default:  
 	 	 var.tfgld131.rtyp =  target(tfgld.rtyp.tax)  
 	 	 break 	 	 	 	 	 	 | #  203051  
 	 endcase  
 	 dump 131
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:131
:SCPAC:tf
:SCMOD:ust
:SFLNO:106
:ICOD:S
:QURY:START
select tfust106.*
from tfust106
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:131
:SCPAC:tf
:SCMOD:ust
:SFLNO:106
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:132
:SCPAC:tf
:SCMOD:ust
:SFLNO:107
:ICOD:D
:QURY:START
on case tfust107.umst  
 	 case tfust.umst.ums:  
 	 	 var.tfgld132.rtyp =  target(tfgld.rtyp.revenue)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.steuer:  
 	 	 var.tfgld132.rtyp =  target(tfgld.rtyp.tax)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.ust.pos:  
 	 	 var.tfgld132.rtyp =  target(tfgld.rtyp.tax.pos)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.land:  
 	 	 var.tfgld132.rtyp =  target(tfgld.rtyp.ccty)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 case tfust.umst.saldo:  
 	 	 var.tfgld132.rtyp =  target(tfgld.rtyp.balance)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 default:  
 	 	 var.tfgld132.rtyp =  target(tfgld.rtyp.tax)  
 	 	 break 	 	 	 	 	 	 | #  203514  
 	 endcase  
 	 dump 132
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:132
:SCPAC:tf
:SCMOD:ust
:SFLNO:107
:ICOD:S
:QURY:START
select tfust107.*
from tfust107
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tf
:TCMOD:gld
:TFLNO:132
:SCPAC:tf
:SCMOD:ust
:SFLNO:107
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ppc
:TFLNO:291
:SCPAC:tp
:SCMOD:ppc
:SFLNO:291
:ICOD:D
:QURY:START
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)  	  |# FP15.n   
 	  determine.posting.type.costs.sundry(  	   	  |# FP9.sn   
 	   	   	  var.tpppc291.teti,   
 	   	   	  posting.type.history.long)   
 	  if cost.history.allow.invoicing(   
 	   	   	   	  tpppc291.cprj,   
 	   	   	   	  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.cohc(1)  =  fill.mc.field.double(tpppc291.amos, 1)   
 	   	  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.txct  =  ""   
 |  	   	  var.tpppc291.cvat  =  ""   
 |  	   	  var.tpppc291.cohc(1)  =  0   
 	   	  var.tpppc291.cohd(1)  =  0   
 	  endif   
 	  dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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,   
 	   	   	   	  3,1,0)   
 	  if reft.csub  =  tppdm.reft.standard then   
 	   	  csub.dsbc  	    =  tppdm035.dsbc   
 	  endif   
 	  if reft.csub  =  tppdm.reft.project then   
 	   	  csub.dsbc  	    =  tppdm635.dsbc   
 	  endif   
 	  csub.dsbc.long  =  etol(csub.dsbc)   
 	  if csub.dsbc.long  =  target(tppdm.dsbc.quantity) then   
 	   	  var.tpptc250.qutm  =  0   
 	   	  var.tpptc250.quan  =  tpptc250.quan   
 	   	  var.tpptc250.cuni  =  tpptc250.cuni   
 	   	  var.tpptc250.cuti  =  ""   
 	  endif   
 	  if csub.dsbc.long  =  target(tppdm.dsbc.time) then   
 	   	  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:62
:VERS:B4cf
: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:62
:VERS:B4cf
: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:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:300
:SCPAC:tp
:SCMOD:ptc
:SFLNO:300
:ICOD:D
:QURY:START
	  var.tpptc300.iexc  =  tppdm600.stus   
 	  dump 1 |   *  dump tpptc300
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:300
:SCPAC:tp
:SCMOD:ptc
:SFLNO:300
:ICOD:S
:QURY:START
select  	  tpptc300.*  , tppdm600.stus  
from 	  tpptc300, tppdm600
where 	  tppdm600.cprj  =  tpptc300.cprj
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:62
:VERS:B4cf
:RELE:61
:CUST:f106
:TCPAC:tp
:TCMOD:ptc
:TFLNO:300
:SCPAC:tp
:SCMOD:ptc
:SFLNO:300
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
