fionad
20th November 2006, 06:09
I have a flag (checkbox) for each record on a multi-occ form for a maintain session. If this checkbox is checked for more than one record an error message needs to be displayed. Also note that only one occurrence of this flag needs to be checked at a given point time.

Please let me know alternative solutions for this check.

bigjack
20th November 2006, 06:37
HI Fionad,

What are you trying to achieve at end ? What happens after the check box is selected by user? Is the user going to print/update the checked records immediately or is the value going to be stored in table for future reference.

Bye

bigjack
20th November 2006, 07:20
Hi,

You can use do.all.occ() for your requirement. You need to write a function which will check whether more than one record is checked. I suggest you count the records which have the flag ticked. If this count is greater than one then prohibit the checking of new record. This function name needs to be passed to do.all.occ() function call.

A pseudo code would look like below:



field.xyz.fff: |substitute with field name
before.input:
count = 0 | global variable
check.input:
do.all.occ(count_check_records)
if count > 1 then
message("Error more than one record is checked")
set.input.error("")
endif

functions:

function count_check_records()
| Function will count the records for which the field is checked/ticked
| It will return the result in global variable count
{
if xyz.fff = checked then
count = count + 1
endif
}


Let me know if you face any problems.

Bye

fionad
20th November 2006, 07:23
This is a maintain session(Multi-occurrence form type) for a table of which one of the fields is a flag which is defined as a checkbox on the form i.e. this box can have only two values "Yes" when checked and "No" when unchecked. While adding records we have to keep a track of how many records have this box checked.If more than one record has the flag checked an error message is displayed, so that for a group of records the flag for only one record is checked. This particular logic is required while maintaining a group of records.

Eg.

Warehouse XYZ
Order Type ABCD

Field1 Field2 Field3(Flag)
A1 XXXX Checked
A2 XXXX Unchecked
A3 XXXX Unchecked

Field3 is the flag that is checked/unchecked
If field3 is checked for both A1 & A2, an error message is displayed and the flag for A2 is reset as unchecked. Another flag(check.flag) has been maintained to keep a track of this . But this is not happening correctly since when we do a page down to maintain for the next set of occurrences. These records are saved in a table

en@frrom
20th November 2006, 10:26
Just keep a boolean flag (let's name it 'flagged') indicating whether for one of the fields the field is set to yes. In the before.program you set it to false. You check your existing data (if available) to see if already the field has been set to yes, and then in the input-check of the 3rd field you check the status. So you write something like:

if field3 = tcyesno.yes then
if flagged then
message("Other record already flagged, only one allowed")
input.again()
else
flagged = true
endif
endif

Of course, according to your script, you should initialize, set and check the variables at the right places...

Regards,
Eli Nager

fionad
21st November 2006, 15:43
Thanks..for the suggestions..

en@frrom
22nd November 2006, 10:00
Did you manage?

fionad
22nd November 2006, 12:47
well not exactly...but i used a flag to check that while saving and closing the session whether at least one record for the group has the flag checked. If no then the error message is displayed.