How about:

TRANS(filename,recID,@RECORD,'x'); IF @ = "" THEN 'not there' ELSE
@<1,fieldno>

On Fri, Oct 8, 2010 at 12:21 PM, Bob Woodward <[email protected]>wrote:

> Can you chain two TRANS functions and compare the results?  If you use
> "C" the first time and "X" the second time then you would be able to
> know if there is no record when the two results are different.  If the
> record doesn't exist, you would only have @ID in the first result but
> the second result would be blank.  If the record does exist and the
> field you are getting is the key value, then the first AND second
> results would be equal, both containing @ID.
>
> BobW
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Oaks, Harold
> Sent: Thursday, October 07, 2010 3:01 PM
> To: U2 Users List
> Subject: Re: [U2] Stumped with TRANS...
>
> George:
>
> Here's something that might work for you, PROVIDED that you always know
> that if the target record exists, there is always something in field 1.
> It seems like this is the situation for you - there is always something
> in that field if the record exists at all.
>
> In the DICT of your main file enter this I-type record.  Let's call it
> CHK.EXIST:
> <1> I
> <2> TRANS(OTHERFILE_NAME,OTHERFILE_KEY,FIELD_1_NAME,'X')
> <3>
> <4>
> <5> 20L    (or whatever)
> <6> S
>
> With the 'X' parameter, if the otherfile record does not exist, then
> nothing (i.e. a zero-length string) is returned, otherwise the content
> of field 1 is returned.  This way you know if the target record exists.
>
> Now you have a second DICT entry, GET.FIELD:
> <1> I
> <2> IF CHK.EXIST THEN
> TRANS(OTHERFILE_NAME,OTHERFILE_KEY,WANTED_FIELD,'X') ELSE 'NO RECORD'
> <3>
> <4>
> <5> 20L
> <6> S
>
> If the otherfile record does not exist, GETFIELD returns the phrase 'NO
> RECORD', otherwise it will return the contents of the field you're
> actually interested in, which may be empty.
>
> Harold Oaks
> Clark County, WA
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of George Gallen
> Sent: Thursday, October 07, 2010 2:20 PM
> To: U2 Users List
> Subject: [U2] Stumped with TRANS...
>
> ok. I'm using TRANS to read some data, but I need to be able to tell if
> the record exists, WITHOUT producing an error message.
>
> ok. So, I use the 'C' command, where it's supposed to return the @ID if
> it doesn't exist
>  BUT....I have records where the only data in <1> is the record ID (by
> coincedence).
>
> so I'd get:
>
> 1  @ID if the record does not exist
> 2  non zero lenth data that happens to be same as @ID (some of the
> records and OK)
> 3  zero length data if the @ID exists, but has no data (which is OK)
> 4  non zero length data that is not the same as the @ID (which is OK)
>
> How can I distinguish between cases 1 and 2 ?
>
> I can't think of any way......and continue using TRANS. I really don't
> want to create a VOC entry for the file
>    then open this temporary file, then read the record. But I might
> have to.
>
>
> George Gallen
> Senior Programmer/Analyst
> Accounting/Data Division, EDI Administrator [email protected]
> ph:856.848.9005 Ext 220
> The Wyanoke Group
> http://www.wyanokegroup.com
>
>
>
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
>
> This e-mail and related attachments and any response may be subject to
> public disclosure under state law.
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
> _______________________________________________
> U2-Users mailing list
> [email protected]
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to