do set_menu
= get_pdt('FREE SERVICE COUPON LIST')
do wait_msg
wait wind '!!! WAIT !!! Gathering Data Using SQL ...' nowa

*do attention with 'This report is based on JOB DATE' + CHR(13) + 'Also JOB CARDS WITH BLANK COUPON NO. WILL NOT BE CONSIDERED'

PRIVATE lnresp
lnresp = 0
DO alert WITH "FREE SERVICE COUPON LIST",1,"\<A ALL;\<B ONLY RECEIVED;\<B NOT RECEIVED COUPON",lnresp

DO CASE
	CASE lnresp = 1
		sele job_mast.coupon_no,jobcard_no,job_dt,job_mast.serviceseq,job_mast.free_rs ;
			from job_mast ;
			where servicetyp = 'F' ;
				and betw(job_dt,date1,date2) ;
			orde by serviceseq,jobcard_no ;	
		 	into cursor query
	CASE lnresp = 2
		sele job_mast.coupon_no,jobcard_no,job_dt,job_mast.serviceseq,job_mast.free_rs ;
			from job_mast ;
			where servicetyp = 'F' ;
				and betw(job_dt,date1,date2) ;
				and ! empt(coupon_no) ;
			orde by serviceseq,jobcard_no ;	
		 	into cursor query
	OTHERWISE 
		sele job_mast.coupon_no,jobcard_no,job_dt,job_mast.serviceseq,job_mast.free_rs ;
			from job_mast ;
			where servicetyp = 'F' ;
				and betw(job_dt,date1,date2) ;
				and empt(coupon_no) ;
			orde by serviceseq,jobcard_no ;	
		 	into cursor query
ENDCASE 
		
if _TALLY > 0
  do prinrepo with 'WFREE_LTR','FREE_LTR','','',''
*	repo form free_ltr noco to (out_file)
*	do out_repo
else
	deac wind wait
	do alert with '!!! No free Service Coupon found for Given Period'
endif
do cls_menu