Declare
 out_file text_io.file_type;
 v_line varchar2(1000);
 title_line varchar2(2000);
 --cfont ole2.obj_type;
 user_file_directory varchar2(300);
 user_file_name varchar2(300);
 
begin
	
	user_file_directory:='z:\eToursBackup\Travel-Billing-Reports\';
	user_file_name:=:GLOBAL.PROGRAM_USER||'-'||:TC||'-'||'TC_WISE_EXCEPTIONS_with_tkt_Details'||'-'||to_char(sysdate,'DD-MON-YY-@HH24-MI')||'.csv';
	user_file_name:=user_file_directory||user_file_name;

 out_file := text_io.fopen(user_file_name, 'w');
 :USER_FILE_NAME_TEXT_BOX:=upper(user_file_name);
 go_block('BCD_ICT_TC_NOT_INVD_TKTS');
 

title_line:='REPORT FROM'||','||:GLOBAL.PROGRAM_USER||':'||:item31;
text_io.put_line(out_file, Title_line);
 
 title_line:='RUN DATE/TIME'||','||to_char(sysdate,'DD-MON-YY-@HH24-MI');
 text_io.put_line(out_file, Title_line);
  
 title_line:='REPORT:'||','||'TC WISE EXCEPTIONS';
 text_io.put_line(out_file, Title_line);
 
  title_line:=:TC||','||:TEXT_ITEM23;
 text_io.put_line(out_file, Title_line);
 
  
  title_line:='CUST'||','||'CUST NAME'||','||'TICKET DATE'||','||'TRAVEL DATE'||','||'AIRLINE'||','||'AIRLINE 

NAME'||','||'PNR'||','||'TICKET_PAX_NAME'||','||
  'TICKET_ROUTING'||','||'CCY'||','||'AMT USD'||','||'AMT KES'
  ||','||'TICKET VALUE IN KES'||','||'TICKET_NUMBER';
 text_io.put_line(out_file, Title_line);
 
 title_line:='  ';
 text_io.put_line(out_file, Title_line);
 
 -- end of change

 first_record;
 loop
  v_line :=  :BCD_ICT_TC_NOT_INVD_TKTS.CUST||','|| :BCD_ICT_TC_NOT_INVD_TKTS.CUST_NAME||','||:BCD_ICT_TC_NOT_INVD_TKTS.TKT_DATE||','|| 

:BCD_ICT_TC_NOT_INVD_TKTS.TRVL_DATE||','|| :BCD_ICT_TC_NOT_INVD_TKTS.AL ||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.AIRLINE_NAME||','|| :BCD_ICT_TC_NOT_INVD_TKTS.PNR||','|| :BCD_ICT_TC_NOT_INVD_TKTS.TICKET_PAX_NAME ||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.TICKET_ROUTING||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.ticket_currency||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.famt_usd||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.famt_kes||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.TICKET_NET_RECEIVABLE||','||
            :BCD_ICT_TC_NOT_INVD_TKTS.TICKET_NO;
  text_io.put_line(out_file, v_line);
  
  if :system.last_record = 'TRUE' then
      exit;
  end if;
  next_record;
 end loop;
 text_io.fclose(out_file);
 
 first_record;

end;