PRIVATE i,j,rco

SELECT RTOINSBODY 
SELECT DOC_NO,COUN(*) tot FROM RTOINSBODY WHERE DOC_NO = 'RTO' GROUP BY DOC_NO INTO CURSOR QUERY
SELECT query
BROWSE
GO top
SCAN	
	SELECT rtoinsbody
	i=1
	SELECT 
	SCAN FOR rtoinsbody.doc_no = query.doc_no 		
			replace sr_no WITH str(i) 
			SELECT rtoinsbody
			i=i+1
	ENDSCAN
	SELECT query
ENDSCAN
SELECT rtoinsbody
BROWSE

 