compile function relational_call( Table, KeysColumn, Key, Popup, TargetTable, SortBy )
begin condition
pre:
post:
end condition
$insert logical
$insert popup_equates
$insert msg_equates
declare function msg, entid, popup, key_sort, repository

KeyList = xlate( Table, Key, KeysColumn,'X' )
*IF @USER4 = 'BRYCE_M' THEN
*   DEBUG
*END
if KeyList <> '' then
    convert @vm to @fm in KeyList
    KeyList = key_sort( KeyList, TargetTable, SortBy, 1, '', '' )
    *convert @fm to ' ' in KeyList
    swap @fm with "' '" in KeyList
    KeyList = "'":KeyList
    KeyList:= "'"
    PopupRec = xlate( 'SYSREPOSPOPUPS', @appid<1>:'**':Popup, '', 'X' )
    PopupRec<pdisplay$> = KeyList
   	Chosen = popup( @window, PopupRec )
    if Chosen = '' and @window <> 'WO_MAST_SCHED' then
        Fchar = TargetTable[1,1]
        Rest  = TargetTable[2,999]
        convert @upper_case to @lower_case in Rest
        TableOut = Fchar:Rest
        MsgInfo = ''
        MsgInfo<micon$> = '?'
        MsgInfo<mcol$>  = -2
        MsgInfo<mrow$>  = -2
        MsgInfo<mtext$> = 'Do you wish to go to the ':TableOut:' window?'
        MsgInfo<mtype$> = 'BNY' 
        Yn = msg( '', MsgInfo )
        if Yn then
            Chosen = 'NoKeys'
        end else
            Chosen = ''
        end
    end
	return Chosen
end else
    return 'NoKeys'
end


