COGNOiSe.com - The IBM Cognos Community

UNICOM Products => UNICOM PowerHouse => Topic started by: cringholz on 12 Aug 2015 08:55:57 AM

Title: Powerhouse programming quiz or qtp help
Post by: cringholz on 12 Aug 2015 08:55:57 AM
I need help to get the last record in a series. 
Ex:  access inputfile link clm to claim of service_x   (select input here)
Inputfile has 1 record, Service_x will return 3 records where service_nbr is 16 characters.
I need to find the one with the highest sequence number, which is the final 3 characters of that field.
1234567890120###
where ### would be 100, 101, 102 etc.  I need to only select the record which contains 102.
Title: Re: Powerhouse programming quiz or qtp help
Post by: ianderson on 20 Aug 2015 06:50:11 AM
You need multiple passes to do this - one to work out what the maximum is, and then a second one to select it.

I wasn't sure whether you meant one record in inputfile per clm, or just one record total. I think the below should work for either. (Note - I haven't tried it)  Written as QTP but could obviously also be done in a 2 pass quiz.

run xyz

request get_maximum
access inputfile link clm to claim of service_x

sort on clm of inputfile

define d'seq char*3 = service_nbr of service_x[14:3]

temp t'max_sequence char*3
item t'max_sequence maximum d'seq reset at clm

subfile max_seq keep at clm include clm, t'max_sequence


request get_record
access *max_seq link clm to claim of service_x

select service_x if t'max_sequence of max_seq eq service_nbr of service_x[14:3]


.... then whatever you need to do with the record