;==File=================================================================;
; POIITEM.DBL
;=======================================================================;
; Copyright 1999 by TAH Software Systems (TAH), Oklahoma City, Oklahoma ;
;									;
;	TAH provides this software under a license and may only be	;
;	used in accordance with the terms and conditions of such	;
;	license and with the inclusion of the above Copyright notice.	;
;==Function=============================================================;
;	po_inq_item	Order line item by item id search routine.
;	poll_poitem	Load List with order line information
;==Changes==============================================================;
; 07/15/1998 TAH - Modify list processing for Synergy V6
;=======================================================================;
.subroutine po_inq_item

	a_key		,a	; IN  - Key value for begin of search
	a_keyno		,n	; IN  - Key number for search
	a_selected	,n	; OUT - True if a valid record selected
				;	False if no record selected
	a_order		,n	; OUT - optional, order number selected

.start nopage,nolist
.include "WND:tools.def"
.include "WND:system.def"
.include "WND:inpctl.def"
.include "UTS:dteut.def"
.include "POS:dtepo.def"

.include "UTS:utcomm.gbl"
.include "POS:pocomm.gbl"
.include "POS:poline.rec"

global data section list_poitem, init
record
	c_itemid	,a24
record	sel_line			; selection window item
	sel_order	,a6			; order number
	sel_linno	,a3			; line number
	sel_locn	,a3			; location code
	sel_buyr	,a3			; buyer code
	sel_vend	,d8			; vendor id
	sel_odate	,a8			; order date
	sel_rdate	,a8			; required date
	sel_oqty	,d9.3			; quantity ordered
	sel_rqty	,d9.3			; quantity received
endglobal

.align
record
	colid		,i4		; column id
	fndid		,i4		; find id
	inpid		,i4		; input column id
	selid		,i4		; selection column id
	req		,i4
	srch		,i4		; search parameter
	field_no	,d3		; field number from i_fldinf
	lfind		,a*,	'i_lxxxxxx'
	  lfind_file	,a6	@lfind+3
	lclass		,a*,	'l_xxxxxx'
	  lclass_file	,a6	@lclass+2
	wind_header	,a160		; window header from script
	  wind_hleft	,a80	@wind_header
	  wind_hright	,a80	@wind_header+80
	wrk_rfa		,d6
.start nopage,list

.proc
	lfind_file = 'poitem'
	lclass_file = lfind_file
	if (a_key.eq.ut_blanks) xreturn		; return if no key value
	c_itemid = a_key

.include "UTS:utfind.inc"

	if (g_entnam.eq.'O_EXIT')
	 then a_selected = FALSE
	 else
	  begin
	    a_selected = TRUE
	    if %passed(a_order) a_order = sel_order
	  end
	xcall e_exit
	xreturn

find_first_match,
	xcall db_find (poline_chan,c_itemid,a_keyno,'M',,,opcde)
	case opcde of
	  begincase
	  1: xcall message (DTER_RNF)
	  2: xcall message (DTER_LOK)
	  endcase
	return

utfind_find,
	return
.end
;=======================================================================;
.subroutine poll_poitem

	a_listid	,n	; IN  - ID for list
	a_request	,n	; IN  - List request code
	a_data		,a	; I/O - Data record area
	a_inpid		,n	; IN  - Input window ID
	a_disabled	,n	; IN  - True/False to disable list item
	a_index		,n	; IN  - List item index

.start nopage,nolist
.include "POS:pocomm.gbl"
.include "UTS:utcomm.gbl"

.include "POS:pohedr.rec"
.include "POS:poline.rec"

global data section list_poitem
record
	c_itemid	,a24
record	sel_line			; selection window item
	sel_order	,a6			; order number
	sel_linno	,a3			; line number
	sel_locn	,a3			; location code
	sel_buyr	,a3			; buyer code
	sel_vend	,d8			; vendor id
	sel_odate	,a8			; order date
	sel_rdate	,a8			; required date
	sel_oqty	,d9.3			; quantity ordered
	sel_rqty	,d9.3			; quantity received
endglobal

record
	wrk_rfa		,d6
.start nopage,list

.proc
	repeat
	  begin
	    xcall db_next (poline_chan,poline,'F','M',,,opcde)
	    unlock poline_chan
	    case opcde of
	      begincase
	      1: a_request = D_LEOF
	      2: a_request = D_LEOF
	      endcase
	     else
	      if (pol_item.eq.c_itemid)
		begin
		  if (pol_comp.eq.ut_cmcomp) .and.
		  &  (pol_linetype.ne.'R') .and.
		  &  (pol_status.ne.'D')
		    begin
		      sel_order = pol_order
		      sel_linno = pol_lineno
		      if (pol_order.ne.pom_order)
			begin
			  pom_comp = pol_comp
			  pom_order = pol_order
			  xcall db_read (pohedr_chan,pohedr,pom_key,0,'M',,,opcde)
			  if (opcde) clear pohedr
			end
		      sel_locn = pol_locncode
		      sel_buyr = pom_buyrcode
		      sel_vend = pom_vend
		      sel_odate = pom_orddate
		      sel_rdate = pol_reqdate
		      sel_oqty = pol_ordqty
		      sel_rqty = pol_recpqty
		      xcall i_display (a_inpid,'set1',sel_line)
		      a_data = sel_line
		      exitloop
		    end
		end
	    if (a_request.eq.D_LEOF) exitloop
	  end
	xreturn
.end
;=======================================================================;

