RayMcManus
New Member
Hi,
I'm having a problem with a piece of code that is supposed to allow more than one user to copy a record from the same screen at the same time. It should look at the last_ord_num variable and automatically increase the order number by one every time another user goes into the screen. The number increases, but keeps the record locked for some reason (even if I put a no-lock command right after the assign), so any other user would get an error message.
Here's the procedure:
define variable order-count as integer no-undo.
define variable assigned-order as logical no-undo.
find first order_ref exclusive-lock no-error.
if not(available(order_ref)) then create order_ref.
assign
stat = true
assigned-order = false.
if order_ref.use_inv_ordnum then
useinvblock:
do:
assign
assigned-order = false.
find inventory where
inventory.stock_num eq order.part_num:screen-value in frame {&active_page} and
inventory.revision eq order.part_rev:screen-value in frame {&active_page} and
inventory.type eq "F" no-lock no-error.
if not(available(inventory)) then
leave useinvblock.
if inventory.ord_num ne "" then
do:
findnextloop:
repeat order-count = 1 to 10000:
find alt-order where
alt-order.ord_num eq inventory.ord_num + "-" + string(order-count)
no-lock no-error.
if not(available(alt-order)) then
leave findnextloop.
end.
if order-count ne 10000 then
assign
order.ord_num = inventory.ord_num + "-" + string(order-count)
order.ord_num:screen-value in frame {&active_page} = string(order.ord_num)
assigned-order = true.
end.
end.
if not(assigned-order) then
do:
do while stat:
assign last_ord_num = last_ord_num + 1.
if not can-find(order where order.ord_num = string(last_ord_num))
then stat=false.
end.
assign
order.ord_num = string(last_ord_num).
order.ord_num:screen-value in frame {&active_page}=string(order.ord_num).
end.
Thanks,
Ray
I'm having a problem with a piece of code that is supposed to allow more than one user to copy a record from the same screen at the same time. It should look at the last_ord_num variable and automatically increase the order number by one every time another user goes into the screen. The number increases, but keeps the record locked for some reason (even if I put a no-lock command right after the assign), so any other user would get an error message.
Here's the procedure:
define variable order-count as integer no-undo.
define variable assigned-order as logical no-undo.
find first order_ref exclusive-lock no-error.
if not(available(order_ref)) then create order_ref.
assign
stat = true
assigned-order = false.
if order_ref.use_inv_ordnum then
useinvblock:
do:
assign
assigned-order = false.
find inventory where
inventory.stock_num eq order.part_num:screen-value in frame {&active_page} and
inventory.revision eq order.part_rev:screen-value in frame {&active_page} and
inventory.type eq "F" no-lock no-error.
if not(available(inventory)) then
leave useinvblock.
if inventory.ord_num ne "" then
do:
findnextloop:
repeat order-count = 1 to 10000:
find alt-order where
alt-order.ord_num eq inventory.ord_num + "-" + string(order-count)
no-lock no-error.
if not(available(alt-order)) then
leave findnextloop.
end.
if order-count ne 10000 then
assign
order.ord_num = inventory.ord_num + "-" + string(order-count)
order.ord_num:screen-value in frame {&active_page} = string(order.ord_num)
assigned-order = true.
end.
end.
if not(assigned-order) then
do:
do while stat:
assign last_ord_num = last_ord_num + 1.
if not can-find(order where order.ord_num = string(last_ord_num))
then stat=false.
end.
assign
order.ord_num = string(last_ord_num).
order.ord_num:screen-value in frame {&active_page}=string(order.ord_num).
end.
Thanks,
Ray