SET stat off 
SET DELETED ON
SET date BRITISH
SET CENTURY on
USE \autosoft\data\88\20122013\saleMast
USE \autosoft\data\88\20122013\booking IN 0
USE \autosoft\data\88\20122013\rtoInsBody IN 0
UPDATE booking set rtoDocNo = ' ' , crtmDocNo = ' ' ;
	WHERE BETWEEN(booking_dt,CTOD('01/04/2012'),CTOD('31/03/2013')) 
SELECT rtoInsBody
SET ORDER TO doc_no
SCAN FOR INLIST(doc_no,'RTO','CRTM')
	WAIT WINDOW 'DOC NO. : ' + doc_no NOWAIT 
	IF SEEK(client_no,'booking','client_no')
		IF doc_no = 'RTO'
			REPLACE booking.rtoDocNo WITH doc_no
			IF SEEK(client_no,'saleMast','client_no')
				REPLACE rtoProfit WITH saleMast.rtoIncome
			ENDIF
		ELSE
			REPLACE booking.rtoDocNo WITH doc_no
			IF SEEK(client_no,'saleMast','client_no')
				IF saleMast.rto_cust = 0
					REPLACE rtoProfit WITH saleMast.rtoIncome
				ENDIF 
			ENDIF 
		ENDIF		
	ENDIF
ENDSCAN

