compile function COC_RPT1() 
begin condition
pre:
post:
end condition
declare function msg, set_property, send_event, dialog_box, utility, get_property
declare subroutine rlist, or_view, activate_save_select, yield
$insert rlist_equates
$insert msg_equates

Params = dialog_box( 'COC_RPT1', @window, '*CENTER' )
if Params = 'CANCEL' or Params = '' then
    return 0
end
open 'SYSLISTS' to SysListsTable else
    MsgInfo = ''
    MsgInfo<mcol$> = -2
    MsgInfo<mrow$> = -2
    MsgInfo<mtext$> = 'Unable to open SYSLISTS...'
    Void = msg( '', MsgInfo )
    return 0
end
ListsId = 'COC_RPT1*':@station
write '' on SysListsTable, ListsId else
    MsgInfo = ''
    MsgInfo<mcol$> = -2
    MsgInfo<mrow$> = -2
    MsgInfo<mtext$> = 'Unable to clear SYSLISTS ':ListsId:'...' 
    Void = msg( '', MsgInfo )
    return 0
end
convert '*' to @fm in Params
CocFrom      = Params<1>
CocThru      = Params<2>
DirToPrinter = Params<3>

Stat = utility( 'CURSOR', 'H' )
Stmt = 'SELECT COC BY WO'
if CocFrom and CocThru then
   Stmt :=  " WITH ENTRY_DATE FROM ":QUOTE(CocFrom):' TO ':QUOTE(CocThru)
end else
	if CocFrom then
	    Stmt := " WITH ENTRY_DATE GE ":QUOTE(CocFrom)
	end
	if CocThru then
	    Stmt := " WITH ENTRY_DATE LE ":QUOTE(CocThru)
	end
end
rlist( Stmt, target_savelist$, ListsId, '', '' )
activate_save_select( ListsId )
if @reccount then
   Cmd = "LIST COC CUST_NAME JUSTLEN 35 WO JUSTLEN 8 PO TOTAL TOT_QTY "
   Cmd:= " HEADING ":'"':"    COC (Shipments) by Work Order                   'T'   PAGE #  'PP''L'    for Selected Dates From (":CocFrom:" ) Thru (":CocThru:")":'" '
   Cmd:= " ID-SUPP"
   if DirToPrinter = 'Yes' then
       rlist( Cmd, 0, '', '', '' )
   end else
       or_view( '', Cmd )
       Void = set_property( 'ORPRV.PRINT', 'ENABLED', 0 )
       WinId = 'ORPRV'
       loop
         while get_property( WinId, 'HANDLE' )
          yield()
       repeat
       ToPrint = ''
       MsgInfo = ''
       MsgInfo<mtext$> = 'Do you want to print this report?'
       MsgInfo<micon$> = '?'
       MsgInfo<mtype$> = 'BNY'
       MsgInfo<mcol$> = -2
       MsgInfo<mrow$> = -2
       MsgInfo<mdefbtn$> = 2 ;* default to no       
       ToPrint = msg( '', MsgInfo )
       if ToPrint then
          activate_save_select( ListsId )
          rlist( Cmd, 0, '', '', '' ) 
       end
   end 
end else
   MsgInfo = ''
   MsgInfo<mtext$> = 'NO Records meeting your date criteria!!'
   MsgInfo<micon$> = '!'
   MsgInfo<mcol$> = -2
   MsgInfo<mrow$> = -2
   Void = MSG( '', MsgInfo )
end
write '' on SysListsTable, ListsId else
    MsgInfo<mtext$> = 'Unable to clear SYSLISTS ':ListsId:'...' 
    MsgInfo<mcol$> = -2
    MsgInfo<mrow$> = -2
    msg( '', MsgInfo )
    return 0
end
RETURN 0
