Checking records during Append
Pickering, John (NORBORD)
John.Pickering at norbord.com
Mon Nov 22 10:24:07 CST 2010
Karen
Gavin is correct. The LOOKUP NOTON will check the existing data in the
table as well as the data on the current screen. I have found this to
work only when the value being checked is a unique key.
I use the technique I suggested earlier when the value to be checked
must be unique within more complicated constraints. For example, I have
a system with a multipurpose codes table. It has two keys: table_id and
table_key. The table_id is the same for all rows in a given table but
there are many such logical tables in the physical data base table. The
table_key must be unique within the table_id but it may repeat many
times in the physical table with unique values for table_id. For
example, the payment terms table (table_id "TERM") may have an entry
with table_key "1" and the order types table (table_id "OTYP") may also
have an entry with table_key "1". The Powerhouse dictionary has a record
for each table and uses the SELECT clause on table_id. The LOOKUP NOTON
construct does not work in this case.
The screen which maintains the table entries must ensure that the
table_key is unique within the table_id. The code I use to do this
follows.
Hope this helps,
JWP
SCREEN MMS012.MMPE &
ACTIVITIES ENTRY,FIND,CHANGE &
ON LINE 25 FOR 23 LINES
FILE ORDER-TYPES PRIMARY OCCURS 18
ACCESS VIA TBL-ID USING "OTYP" ; added to solve bug in 8.19
FILE ORDER-TYPES REFERENCE ALIAS ORDER-TYPES-2
SELECT IF TBL-ID = "OTYP"
USE SYSTITLE.MMS NOL NOD
TITLE "MMS012" AT 2,1
TITLE "Order Types Table" CENTRED AT 2,40
SKIP TO 4
TITLE "Code" AT ,4
TITLE "Description" AT ,9
ALIGN (1,,4) (,,9)
CLUSTER OCCURS WITH ORDER-TYPES
FIELD ORDER-TYPE OF ORDER-TYPES REQUIRED NOCHANGE
FIELD DESCRIPTION OF ORDER-TYPES REQUIRED
PROCEDURE EDIT ORDER-TYPE
BEGIN
FOR ORDER-TYPES
BEGIN
IF OLDVALUE(ORDER-TYPE OF ORDER-TYPES) NE "" AND &
OLDVALUE(ORDER-TYPE OF ORDER-TYPES) = FIELDTEXT
THEN ERROR 001 ; value already on screen
END
GET ORDER-TYPES-2 &
VIA TBL-KEY USING ORDER-TYPE OF ORDER-TYPES OPT
IF ACCESSOK
THEN ERROR 002 ; value already on file
END
BUILD
________________________________
From: Karen Barrett [mailto:kbarrett00 at hotmail.com]
Sent: Monday, November 22, 2010 10:50 AM
To: Pickering, John (NORBORD); PowerhouseList Post
Subject: RE: Checking records during Append
Thank you John, a code example would be helpful.
________________________________
Subject: Re: Checking records during Append
Date: Sat, 20 Nov 2010 22:10:16 -0500
From: John.Pickering at norbord.com
To: kbarrett00 at hotmail.com
I'd send you a code sample if I wasn't in a car half way between
Montreal and Toronto. Ask me on Monday if you would still like an
example.
JWP
________________________________
From: Karen Barrett <kbarrett00 at hotmail.com>
To: Pickering, John (NORBORD); PowerhouseList Post
<powerh-l at lists.sowder.com>
Sent: Sat Nov 20 21:35:50 2010
Subject: RE: Checking records during Append
Hi John,
So in the edit I first check the stored records, then loop through
whatever is displayed. Thanks!!!
Hey, I passed up turkey bingo to work tonight :-)
Karen
________________________________
Subject: Re: Checking records during Append
Date: Sat, 20 Nov 2010 21:15:42 -0500
From: John.Pickering at norbord.com
To: kbarrett00 at hotmail.com; powerh-l at lists.sowder.com
You will need to loop through the existing values on the screen in the
EDIT PROCEDURE comparing FIELDVALUE with the data item of the other
occurrences. You will need to check OCCURRENCE to avoid comparing
FIELDVALUE with the data item in its own occurrence.
And why am I answering this on a Saturday evening? :-)
JWP
________________________________
To: PowerhouseList Post <powerh-l at lists.sowder.com>
Sent: Sat Nov 20 21:06:21 2010
Subject: Checking records during Append
Does anyone remember what the trick is to checking between records
entered (occurs 10) during the Append process?
Alternately, is there a way to push update stay from inside the Append?
Old record xx yy zz 11 22
Old record zz rr 33 44 77
New rec zz qq 33 44 66 ;my edits work fine here, checking against the
put records
New rec zz qq 33 99 66 ; Here, the edits do not work because I am
mid-append, data not yet stored. The value 33 is not allowed for the 2nd
of paired
; records but the data is not
saved yet.
Thanks for any tips,
Karen Barrett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.sowder.com/pipermail/powerh-l/attachments/20101122/bc8bf567/attachment-0001.htm
More information about the powerh-l
mailing list