I have a scenario where I have in input order num,Order time,Item id and B(buy)/D(Donot Buy) Indicator. But I need to take only the latest indicator based ontime for each order num.
Input:
--Ord num--|-----Ord time---------|--Item id--|--Ind--
0702272089 10/26/2009 13:10:36 456664554 B
0702272089 10/26/2009 12:10:36 456664552 D
0702272089 10/26/2009 11:10:36 456664652 B
0702272090 10/26/2009 13:10:36 456664552 D
Output:
--Ord num--|-----Ord time---------|--Item id--|--Ind--
0702272089 10/26/2009 13:10:36 456664554 B
0702272089 10/26/2009 12:10:36 456664552 B
0702272089 10/26/2009 11:10:36 456664652 B
0702272090 10/26/2009 13:10:36 456664552 D
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Prajesh,
In the only example of records with multiple order numbers, you show them as already sorted descending by date and time so the indicator you want would be in the first record with that key. Is that always the case or can the indicator you want NOT be in the first record with a key. For example, could you have:
1702272089 10/26/2009 12:10:36 456664552 D
1702272089 10/26/2009 11:10:36 456664652 B
1702272089 10/26/2009 13:10:36 456664554 B
so the last record is the one you want the indicator from? If you can have a set of records like this, what would you expect for the output records?
Also, what is the RECFM and LRECL of the input file, and what is the starting position, length and format of each input field?
I want to take only the latest information keyed in for an ordernum. hence I am taking the decision in the latest record.
Frank,
I Need to do a sort on the order num Asc and order time desc, which will make sure that I ll get the latest business decsion on top. It wud be great if I can combine this sort also into the solution. In, simple, I need the latest Decsion( B or D) for an ordernnum, nomatter how many items are there under that ordernum! and this needs to be propagated to all items under that ordernum.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
It would have helped if you'd answered all of my questions so I wouldn't have to make assumptions, but I suspect a DFSORT job like the following will do what you asked for: