Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confused about using [LAST]

Status
Not open for further replies.

eyetry

Programmer
Oct 2, 2002
560
0
0
US
I'm trying to use the [LAST] function but can't get it to work correctly.

I'm trying to get the current record and the last record processed. Problem is that, depending on how I write the rule, I get two copies of the same record or the record returned with the 'LAST' function is the last record in the file.

TREE =
file:
loop_group:
record:
FIELD1 = REC-TYPE
FIELD2 = ID
FIELD3 = CODE
FIELD4 = NAME
FIELD5 = IND

Data =
A1|123454|A|JONES|P
A1|123455|A|JOHNSON|P
A1|123456|A|SMITH|P
A1|123456|T|SMITH|P
A1|123457|A|THOMPSON|P

functional map rule = f_map (record:loop_group:file, record[LAST]:loop_group:file)

gives me 'A1|123456|T|SMITH|P' and 'A1|123456|T|SMITH|P'

functional map rule = f_map (record:loop_group:file, record:loop_group[LAST]:file)

gives me 'A1|123456|T|SMITH|P' and 'A1|123457|A|THOMPSON|P'

what I'm looking for is

'A1|123456|T|SMITH|P' and 'A1|123456|A|SMITH|P'

Any help?

ps: What I really need to do is determine if current record FIELD2 = previous record FIELD2 & previous record FIELD3 = 'A'
 
LAST a special index value that refers to the last data object of a particular series.

Copyright © 2003 by Mercator Software, Inc.

Looks like you need a control break in the Type Tree
 
janhes....

tree defined as

file
-header_record
-member_loop (1:S)
--subscriber
--coverage
--dependent (0:S)
-trailer_record

the data is really more like

hdr:data
sub:A1|123454|A|JONES|P
cov:data|data|....
sub:A1|123455|A|JOHNSON|P
cov:data|data|....
dep:data|data|....
cov:data|data|....
sub:A1|123456|A|SMITH|P
cov:data|data|....
sub:A1|123456|T|SMITH|P
cov:data|data|....
sub:A1|123457|A|THOMPSON|P
cov:data|data|....
trl:data

probably a dumb question but... isn't the member_loop the cntl_break? ie.... the f_map is run based on the presence of the member_loop..

Also, what I'm really trying to get to is... if current code = "T" and current sub = last sub ignore current member_loop..... (yes loops are sorted in so code 'T' subs always appear last when a members have multiple loops)

 
But have you specified any rules in your type tree for the control break?
 
added control break but still ended up getting the current record as last record

current: A1|123456|T|SMITH|P
last: A1|123456|T|SMITH|P

instead of:

current: A1|123456|T|SMITH|P
last: A1|123456|A|SMITH|P

It's a small file so I think I'll just pass the current record and the file the use a lookup. Seems like a lot of overhead that way but..... for the size of the file.....

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top