QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:D
:QURY:START
	 if get.business.partner(tccom010.cuno,bcstc.orgn.cuno, o.mess) then  
 	 	 var.tccom100.bpid =  ""        
 	 	 continue  
 	 else  
 	 	 var.tccom100.bpid =  bcstc008.bpid  
 	 	 if bcstc008.sndr =  empty then 	 	 | #  146484.sn  
 	 	 	 var.tccom100.sndr =  tcyesno.no  
 	 	 else 	 	 	 	 	 | #  146484.en  
 	 	 	 var.tccom100.sndr =  bcstc008.sndr  
 	 	 endif 	 	 	 	 	 | #  146484.n  
 	 	 if var.tccom100.sndr =  tcyesno.yes then 	 	 | #  FP3.sn  
 	 	 | *  One -  Time BP should not get a Parent BP filled.  
 	 	 	 var.tccom100.prbp =  ""          
 	 	 else  
 	 	 	 var.tccom100.prbp =  hold.tccom100.prbp  
 	 	 endif 	 	 	 	 	 	 | #  FP3.en  
 	 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  
 	  
 	 dump 1  
 	  
 	 if (tccom010.comp <>  0) then  
 	 	 if get.enterprise.unit(tccom010.comp,hold.cmpnr, o.mess) then  
 	 	 	 var.tccom110.cofc =  ""        
 	 	 else  
 	 	 	 var.tccom110.cofc =  bcstc018.sofd  
 	 	 endif  
 	 else  
 	 	 var.tccom110.cofc =  ""        
 	 endif  
 	 if isspace(var.tccom100.prbp) or isspace(tccom010.pcpr) then | #  200003.sn  
 	 	 var.tccom110.bppr =  ""        
 	 else 	 	 	 	 	 | #  200003.en  
 	 	 if get.business.partner(tccom010.pcpr,bcstc.orgn.cuno, o.mess) then  
 	 	 	 var.tccom110.bppr =  ""        
 	 	 else  
 	 	 	 var.tccom110.bppr =  bcstc008.bpid  
 	 	 endif  
 	 endif 	 | #  200003.n  
 	 dump 2  
 	 dump 3  
 	 if isspace(tccom010.cinm) then  
 	 	 var.tccom112.cinm =  bcstc000.cinm  
 	 else  
 	 	 var.tccom112.cinm =  tccom010.cinm  
 	 endif  
 	  
 	 var.tccom112.cvyn =  get.tax.flag.via.bp(tccom010.cuno, bcstc.orgn.cuno,  
 	 	 	 o.mess)  
 	 if get.business.partner(tccom010.pctf,bcstc.orgn.cuno, o.mess) then 	 | #  148806.sn  
 	 	 var.tccom112.pfbp =  ""        
 	 else  
 	 	 var.tccom112.pfbp =  bcstc008.bpid  
 	 endif 	 	 	 	 	 	 	 | #  148806.en  
 	 dump 4  
 	 dump 5  
 	  
 	 add.business.partner.to.list(var.tccom100.bpid) 	 | #  800 -  141749.n  
 	 create.bps.for.delivery.adresses() 	 	 | #  201931.n  
 	 	 	 	 	 	 	 | #  218119.sn
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:100
:SCPAC:tc
:SCMOD:com
:SFLNO:010
:ICOD:F
:QURY:START
	 	 	  
 	 sort.bp.code.list() 	 	 	 	  
 	 	 	 	 	 	 	 | #  218119.en
:QURY:END
:TEXT:

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:com
:TFLNO:130
:SCPAC:bc
:SCMOD:stc
:SFLNO:004
:ICOD:D
:QURY:START
| 	 if bcstc004.reqd =  tcyesno.yes then 	 	 	 | #  City.o  
 	 	 | *  Dump selected addresses.  
 	 	 if isspace (bcstc004.nama) then  
 	 	 	 var.tccom130.nama =  bcstc004.cadr(1;9) &   
 	 	 	 	 	 	 empty.string (1;26)  
 	 	 else  
 	 	 	 var.tccom130.nama =  bcstc004.nama  
 	 	 endif  
 	  
 	 	 if (bcstc004.lvdt =  0) then  
 	 	 	 var.tccom130.lvdt =  utc(0,0)  
 	 	 else  
 	 	 	 var.tccom130.lvdt =  utc(bcstc004.lvdt,0)  
 	 	 endif  
 	 	 | *  Dump Addresses -  Freight Management.  
 	 	 if bcstc004.tadr <>  "" then                                                                            
 	 	 	 select tracs100.creg:var.fmfmd010.creg,  
 	 	 	 	 tracs100.lwtm:var.fmfmd010.lwtm,  
 	 	 	 	 tracs100.lltm:var.fmfmd010.ldtm,  
 	 	 	 	 tracs100.uwtm:var.fmfmd010.uwtm,  
 	 	 	 	 tracs100.ultm:var.fmfmd010.untm,  
 	 	 	 	 tracs100.hono:var.tccom130.hono,  
 	 	 	 	 tracs100.pobx:g.tccom130.pobn  
 	 	 	 from 	 tracs100  
 	 	 	 where tracs100._index1 =  {:bcstc004.tadr}  
 	 	 	 as set with 1 rows  
 	 	 	 selectdo  
 	 	 	 	 var.fmfmd010.lwtm =  var.fmfmd010.lwtm *  g.conv.factor  
 	 	 	 	 var.fmfmd010.ldtm =  var.fmfmd010.ldtm *  g.conv.factor  
 	 	 	 	 var.fmfmd010.uwtm =  var.fmfmd010.uwtm *  g.conv.factor  
 	 	 	 	 var.fmfmd010.untm =  var.fmfmd010.untm *  g.conv.factor  
 	 	 	 	 var.tccom130.pobn =  left.align(g.tccom130.pobn,10)  
 	 	 	 	 dump 2 | *  Addresses -  Freight Management (fmfmd010)  
 	 	 	 selectempty  
 	 	 	 	 var.tccom130.hono =  empty.string(1;10)  
 	 	 	 	 var.tccom130.pobn =  empty.string(1;10)  
 	 	 	 endselect  
 	 	 else  
 	 	 	 var.tccom130.hono =  empty.string(1;10)  
 	 	 	 var.tccom130.pobn =  empty.string(1;10)  
 	 	 endif  
 	 	 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  
 | 	 	 dump 3 | *  Cities by Country (tccom139)  
 | 	 endif  
 | 	 var.prev.country =  bcstc004.ccty  
 | 	 var.prev.city.code =  bcstc004.ccit 	 	 	 	 | #  City.eo
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tc
:TCMOD:mcs
:TFLNO:002
:SCPAC:tc
:SCMOD:mcs
:SFLNO:002
:ICOD:D
:QURY:START
	 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  
 	 Dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:005
:SCPAC:tf
:SCMOD:acp
:SFLNO:005
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:103
:SCPAC:tf
:SCMOD:acp
:SFLNO:151
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:311
:SCPAC:tf
:SCMOD:acp
:SFLNO:311
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:312
:SCPAC:tf
:SCMOD:acp
:SFLNO:312
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:313
:SCPAC:tf
:SCMOD:acp
:SFLNO:313
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:314
:SCPAC:tf
:SCMOD:acp
:SFLNO:314
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:315
:SCPAC:tf
:SCMOD:acp
:SFLNO:315
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:460
:SCPAC:tf
:SCMOD:acp
:SFLNO:260
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acp
:TFLNO:461
:SCPAC:tf
:SCMOD:acp
:SFLNO:261
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:acr
:TFLNO:103
:SCPAC:tf
:SCMOD:acr
:SFLNO:151
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:002
:SCPAC:tf
:SCMOD:cmg
:SFLNO:002
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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  
 	 select tfcmg007.*  	  
 	 from tfcmg007  
 	 where tfcmg007._index2 =  {:tfcmg003.paym}  
 	 as set with 1 rows  
 	 selectdo  
 	 	 var.tfcmg003.poda =  1  
 	 selectempty  
 	 	 var.tfcmg003.poda =  2  
 	 endselect 	  
 	 dump 1
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:003
:SCPAC:tf
:SCMOD:cmg
:SFLNO:003
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:101
:SCPAC:tf
:SCMOD:cmg
:SFLNO:101
:ICOD:S
:QURY:START
select tfcmg101.*
from tfcmg101
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:103
:SCPAC:tf
:SCMOD:cmg
:SFLNO:103
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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  
 	  
 	 dump 1
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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
:QURY:END
:TEXT:

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

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:131
:SCPAC:tf
:SCMOD:cmg
:SFLNO:117
:ICOD:D
:QURY:START
	 if get.business.partner(tfcmg117.suno,bcstc.orgn.suno,var.err.mess) then  
 	 	 var.str.bpid =  ""                                    
 	 else  
 	 	 var.str.bpid =  bcstc008.bpid  
 	 endif  
 	  
 	 	 | *  Dump records from tfcmg117  
 	 	 on case 	 tfcmg117.cost  
 	 	 	 case 	 tfcmg.cost.cost.00:  
 	 	 	 	 var.coal =  1 	 | *  tfcmg.coal.transfer.fee  
 	 	 	 	 break  
 	 	 	 case 	 tfcmg.cost.cost.01:  
 	 	 	 	 var.coal =  2 	 | *  tfcmg.coal.whole.fee.payer  
 	 	 	 	 break  
 	 	 	 case 	 tfcmg.cost.cost.02:  
 	 	 	 	 var.coal =  3 	 | *  tfcmg.coal.whole.fee.payto  
 	 	 	 	 break  
 	 	 	 default:  
 	 	 	 	 var.coal =  1 	  
 	 	 endcase  
 	 	  
 	 	 var.anno =  tcyesno.no  
 	 	 select 	 tfcmg103.amth  
 	 	 from 	 tfcmg103  
 	 	 where 	 tfcmg103.btno =  :tfcmg101.btno  
 	 	 and 	 tfcmg103.suno =  :tfcmg101.suno 	  
 	 	 and 	 tfcmg103.basu =  :tfcmg101.basu 	  
 	 	 and 	 tfcmg103.reas =  :tfcmg101.reas 	  
 	 	 and 	 tfcmg103.ccur =  :tfcmg101.ccur 	  
 	 	 and 	 tfcmg103.paym =  :tfcmg101.paym 	  
 	 	 and 	 tfcmg103.srno =  :tfcmg101.srno 	  
 	 	 and 	 tfcmg103.blac =  :tfcmg101.blac  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 if tfcmg103.amth >  5000 then  
 	 	 	 	 var.anno =  tcyesno.yes  
 	 	 	 else  
 	 	 	 	 var.anno =  tcyesno.no  
 	 	 	 endif  
 	 	 endselect  
 	 	  
 	 	 select 	 tfcmg001.buba  
 	 	 from 	 tfcmg001  
 	 	 where 	 tfcmg001.bank =  :tfcmg101.bank  
 	 	 as set with 1 rows  
 	 	 selectdo  
 	 	 	 var.oadt =  etol(tfcmg001.buba)  
 	 	 endselect  
 	 	 dump 131
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:131
:SCPAC:tf
:SCMOD:cmg
:SFLNO:117
:ICOD:S
:QURY:START
select 	 tfcmg117.*  , tfcmg101.*   
 	
from 	 tfcmg117, tfcmg101  
 	
where 	 tfcmg117.btno =  tfcmg101.btno  
 	 and 	 tfcmg117.suno =  tfcmg101.suno  
 	 and 	 tfcmg117.comp =  tfcmg101.comp  
 	
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:131
:SCPAC:tf
:SCMOD:cmg
:SFLNO:117
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:204
:SCPAC:tf
:SCMOD:cmg
:SFLNO:204
:ICOD:S
:QURY:START
select tfcmg204.*
from tfcmg204
:QURY:END
:TEXT:

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:507
:SCPAC:tf
:SCMOD:cmg
:SFLNO:950
:ICOD:D
:QURY:START
	 dump 507
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:507
:SCPAC:tf
:SCMOD:cmg
:SFLNO:950
:ICOD:S
:QURY:START
select tfcmg950.*
from tfcmg950
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:cmg
:TFLNO:507
:SCPAC:tf
:SCMOD:cmg
:SFLNO:950
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

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

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

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

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

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

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

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

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:102
:SCPAC:tf
:SCMOD:gld
:SFLNO:102
:ICOD:S
:QURY:START
select tfgld102.*
from tfgld102
:QURY:END
:TEXT:

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

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

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:116
:SCPAC:tf
:SCMOD:gld
:SFLNO:199
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:117
:SCPAC:tf
:SCMOD:gld
:SFLNO:198
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:130
:SCPAC:tf
:SCMOD:ust
:SFLNO:100
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:131
:SCPAC:tf
:SCMOD:ust
:SFLNO:106
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
QRY
:MPRF:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
: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:28
:VERS:B4fb
:RELE:61
:CUST:sy30
:TCPAC:tf
:TCMOD:gld
:TFLNO:132
:SCPAC:tf
:SCMOD:ust
:SFLNO:107
:ICOD:X
:QURY:START
  
:QURY:END
:TEXT:

:TEXT:END
