'Chk_Ancl - list ancillaries needed during next 14 days

external  vloadif() dpath messboxwait() Background() vunloadif() remove()
external  X_path _SWIP_Crystal() Xreppath progress() cpath PrintReport()

public    #prec ptstr

global    x p1 p2 p3 p4 p5 p6 ReturnToMenu()


MAIN
single-step off
	file unload all
  	Background()
'   remove(dpath|"immtancl.*")
'   p1 = "anclimmt.dfr"   ' p1 = report definition ("ord_stck.dfr")
'   p2 = ""               ' p2 = title at top of choice popup ("LABEL")
'   p3 = 1                ' p3 = printer to be used (1=HPIII_QC; 2=GEN_EPSN etc)
'   p4 = 1                ' p4 = printer port to use (1,2 etc - network set to use 2=LASER; 3=LABEL)
'   p5 = 1                ' p5 = choose VIEW/PRINT 1=PRINT; 2=VIEW; 3=CHOOSE
'   p6 = 1                ' p6 = nr of copies

	progress(15,10," Please wait ... preparing data ",0)
  	vloadif(dpath|"goodsout.vws")
  	order change key "[Date_Out]"
  	data goto record first
  	data find "[Date_Out]" greater-than today options ""
  	#prec=precord
  	data query execute "anclimt1.dfq" index "anclimt1.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
' ³ precord>=#prec and not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  	if cerror
    		messboxwait(" No ancillaries due out after today ",0,0,1)
    		exit main
  	end if
  	vunloadif("goodsout.vws")
  	vloadif(dpath|"anclimt1.vw")
  	order change index "anclimt1.idx"
   	remove(dpath|"immtancl.*")
  	data query execute "anclimmt" Smart4 dpath|"immtancl" fields "[Job_Nr;Requsn_Nr;Date_Out;QuantOut;Itemtype;Product_Code]"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   days([Date_Out])>days(today)
'   and
'   days([Date_Out])<=(days(today)+14)
'   and
'   [Itemtype]="A"
'   and not (deleted)
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  	if cerror
    		messboxwait(" No ancillaries due out after today ",0,0,1)
    		exit main
  	end if
  	order key add "[Product_Code]"
  	keys F10
  	vloadif(dpath|"anclimt2.vw")
  	data query execute "anclimt2.dfq" index "anclimt3.idx"
' ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
'   [TotalNeeded]>.1
' ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
  	if cerror
    		messboxwait(" No ancillaries due out after today ",0,0,1)
    		exit main
  	end if
  	order sort now dictionary "anclimt4.idx" fields "[Product_MRC]" ascending

' repaint on
' repaint
' single-step on

   	vunloadif("X_ancimt.vws")
   	remove(X_path|"X_ancimt.*")

   	data query execute "not_del.dfq" Smart4 X_path|"X_ancimt" fields\
"[Product_MRC;PhysicalBalance;TotalNeeded;MinStock]"
   	_SWIP_Crystal(Xreppath|"Xancimmt","S",0,1,"")

  	ReturnToMenu()

END MAIN


FUNCTION ReturnToMenu()
  Background()
  file unload all
  transfer cpath|"pm_menu.psl" in-memory
END FUNCTION ' ReturnToMenu()
