nolihayati isma
3rd July 2013, 04:35
Hi all,
Need your advise. I am using form type 3 with 13 occurances.
User having 2 choices to update the records within 1 order.
1) choice = Add.set - add new item and I am able to control duplicate item without issue by checking in after.input
2) choice = modify.set - user will update existing order and might be change the item. I need to check the new updated item must not duplicate within same order. How I can make a check for this situation? I am try the same method as per add.set but failed.
Anybody, can assist me please.
vamsi_gujjula
3rd July 2013, 11:39
if it is a key field (part o index), it will not allow you to save the records(it will pop a msg saying skip ..). i am not really sure what your requirement is.
mark_h
3rd July 2013, 17:04
And if it is not a key field then what you do is in the check input run a quick check against the table to make sure it is not already on the table. Then - since this is a multi-occurrence session you have to check the screen for other possible updates. Below is a sample of how we do this for line numbers. I am assuming that the view field is something like make item and the occurrence field has something like sub-item.
function long get.next.tdvss130.line()
{
select max(tdvss130_1.line):max.line
from tdvss130 tdvss130_1
where tdvss130_1._index1 = {:tdvss130.logn,:tdvss130.seqn}
selectdo
selectempty
max.line = 0
endselect
search.last.used.line.on.screen()
max.line = max.line + 1
return(max.line)
}
function search.last.used.line.on.screen()
{
long i
for i = 1 to (filled.occ - 1)
do.occ(i ,check.last.used.line)
endfor
}
function check.last.used.line()
{
if tdvss130.line > max.line then
max.line = tdvss130.line
endif
}
nolihayati isma
4th July 2013, 04:08
Hi,
item code not part of index and i need to check manually to avoid duplicate.
below input triggered via add.set
Form as below. Original input.
seqn item code supplier desc price
----- --------- -------- --------- ------
1 ABC abd_desc 10
2 123 123_desc 2
3 456 CDE cde_desc 3
Users are allowed to modify the code in modify.set but I dont want to allow
user to enter duplicate item code. They can update seqn 1 with other values but not 123 or 456. They can change others seqn but the item code must not duplicate. That's my requirement.
seqn item code supplier desc price
----- --------- -------- --------- ------
1 ABC abd_desc 10
2 123 123_desc 2
3 456 CDE cde_desc 3
nolihayati isma
4th July 2013, 06:26
sorry....the sample given is out of alligment. 1st row, the item code is blank
bhushanchanda
4th July 2013, 07:34
There are a lot of options. Well here's one more thing you can do, you can use:-
field.fieldname:
before.input:
|get the current item name in a variable and also the index fields of the current record in some variables:-
curr.item = field_name
a = field_name | Index part 1 of current record
b = field_name | Index part 2 of current record
| .. .. number of parts
when.field.changes:
|Get the new item name in a variable.
new_item = field_name
|Now check if this item is present in the table against the same index or not using a select loop.
select table_name.*
from table_name
where table_name._index1 = {:a , :b}
and table_name.item = :new_item
selectdo
message("Duplicates not allowed")
field_name = curr.item
endselect
nolihayati isma
4th July 2013, 11:29
Hi Bhushan,
The problem resolved with your solution :). Below is the lastest code
before.input:
item.ori = tsrep124.item
a = tsrep124.orno | Index part 1 of current record
when.field.changes:
item.mod = tssma102.item
select tsrep124.*
from tsrep124
where tsrep124._index1 = {:a}
and tsrep124.item = :item.mod
selectdo
message("Item Code is duplicated")
input.again()
tsrep124.item= item.ori
endselect
bhushanchanda
4th July 2013, 11:45
Good. Glad that worked for you. :)
vamsi_gujjula
4th July 2013, 11:57
if i am not wrong, you dont want duplicate item at any point of time..... and also you dont want duplicate seq at any point of time ..........
in that case i would have two indexs.
1) order no. , seq.no ----> this makes sure for single order you dont have duplicate seq.no
2)order no , item ----> this makes sure for single order you dont have duplicate items
if you want to check for duplicate only while modifying the record then i think you need to code otherwise i dont think.