DO set_menu
= get_pdt('FREE SERVICE ANALYSIS')
SELECT CLIENT,SALE_DT,IIF(EMPTY(FREE_01_DT),'','Y') AS FIRST_FLG ,;
	IIF(EMPTY(FREE_02_DT),'','Y') AS SECOND_FLG ,;
	IIF(EMPTY(FREE_03_DT),'','Y') AS THIRD_FLG	,;
	IIF(EMPTY(FREE_04_DT),'','Y') AS FOURTH_FLG	,;
	IIF(EMPTY(FREE_05_DT),'','Y') AS FIFTH_FLG	,;
	IIF(EMPTY(FREE_06_DT),'','Y') AS SIXTH_FLG,MODELCOLNO,STATUS, ;
	mobile,vehicle_no ;
	FROM CLIENT ;
	WHERE BETWEEN(SALE_DT,DATE1,DATE2) ;
	ORDER BY sale_dt ;
	INTO CURSOR QUERY READWRITE 
SCAN 
	IF STATUS = 'R' AND EMPTY(sixth_FLG) AND (! EMPTY(fifth_FLG) OR ! EMPTY(fourth_FLG) OR ! EMPTY(third_FLG) OR ! EMPTY(second_FLG) OR ! EMPTY(first_flg))
		REPLACE sixth_FLG WITH 'N'
	ENDIF 
		
	IF ! EMPTY(SIXTH_FLG) AND EMPTY(FIFTH_FLG)
		REPLACE FIFTH_FLG WITH 'N'
	ENDIF 
	IF ! EMPTY(FIFTH_FLG) AND EMPTY(FOURTH_FLG)
		REPLACE FOURTH_FLG WITH 'N'
	ENDIF 
	IF ! EMPTY(FOURTH_FLG) AND EMPTY(THIRD_FLG)
		REPLACE THIRD_FLG WITH 'N'
	ENDIF 
	IF ! EMPTY(THIRD_FLG) AND EMPTY(SECOND_FLG)
		REPLACE SECOND_FLG WITH 'N'
	ENDIF 
	IF ! EMPTY(SECOND_FLG) AND EMPTY(FIRST_FLG)
		REPLACE FIRST_FLG WITH 'N'
	ENDIF 
ENDSCAN 

COPY TO hhml TYPE XLS 

DO PRINREPO WITH 'WHHML','HHML','',''
DO cls_menu