I have an ACCOUNT_NO, REF_NO, REASON_CODE and VALID_DATE fields in the input file .
( Input file is already sorted on ACCOUNT_NO, REF_No and VALID_DATE fields.)
For each ACCOUNT_NO who's REFERENCE_NO is same and has multiple REASON CODE, then I should process the last record with REASON_CODE with highest VALID_DATE in the output,
If there is no REASON_CODE then simply write Highest VALID_DATE in the output file based on ACCOUNT_No AND REFERENCE_NO as shown below:
However, the code which Im using is processing only the last records from the each of the group irrespective of the VALID_DATE, the main aim of the sort is to get the last closed accounts with REASON_CODE and current accounts(whos Valid date = 9999-12-31)
Code:
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(2,06,PD) ON(7,4,BI) LAST USING(CTL1)
/*
//CTL1CNTL DD *
INCLUDE COND=(11,4,CH,NE,C' ')
So could you please let me know if I can use any other conditions to achieve the above requirement.
However, the code which Im using is processing only the last records from the each of the group irrespective of the VALID_DATE, the main aim of the sort is to get the last closed accounts with REASON_CODE and current accounts(whos Valid date = 9999-12-31)
Code:
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(2,06,PD) ON(7,4,BI) LAST USING(CTL1)
/*
//CTL1CNTL DD *
INCLUDE COND=(11,4,CH,NE,C' ')
So could you please let me know if I can use any other conditions to achieve the above requirement.
Why not to add extra selection?
Code:
//CTL1CNTL DD *
INCLUDE COND=(11,4,CH,NE,C' ',
AND,date_pos,10,CH,EQ,C'9999-12-31')
date_pos is impossible to find from your description, but you personally must know it.
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
Code:
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(2,06,PD) ON(7,4,BI) LAST USING(CTL1)
/*
//CTL1CNTL DD *
INCLUDE COND=(11,4,CH,NE,C' ')
OK, it is a long long time since I've been allowed access to a mainframe so maybe this is a little off target ................... so if I'm wrong let me know
But you have a condition shown above that tests for 11,4,CH,NE,C' ' - and I can only guess that this relates to the field Reason_c as your data representation has nothing but C' ' in position 11 - so please learn to match your data samples with your code statements.
But I digress ................
To me that statement only includes all records without 4 C' ' at pos 11, but your output shows records with 4*C' ' included.
Perhaps I have not fully understood your request, or that you haven't made it idiot-proof simple to understand.
As I have said it is about four years since I have played on the mainframe, so maybe I am wrong.
I will also ask if the statements above have been tested by you, and if so what results did you get.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
Hi expat,
Looks like the OP needs the blank reason code record in output when there are no non-blank reason codes for that Account+Reference number, (if there are non-blank reason code records, then get the one with the max-date). If he runs his card as is, he won't get such records in the output, so I think he is trying to get those into the output as well.
naveen katkuri,
For 'current accounts' will there be duplicates on Account+Reference number?
Or will it be just one record with a blank reason code and date='9999-12-31'?
sergeyken wrote:
Why not to add extra selection?
Code:
INCLUDE COND=(11,4,CH,NE,C' ',
AND,date_pos,10,CH,EQ,C'9999-12-31')
sergeyken,
This will return nothing. For non blank reason codes, the dates are NOT='9999-12-31'.
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
expat - Glad you are back.
naveen katkuri,
Fields(p,l) >> 2,6 and 7,4 are overlapping in your control statements, Is that a typo? If those are contiguous, you can probably combine into one 10-byte key.
Here is an example using a COPY operation that might help you.
The example assumes the input to be of FB/LRECL=80 and the key (account+reference) at pos-1, length-15 and the date field at pos-32 and length-10. The idea is to assign a sequence number to each record in the acct-reference group and then OMIT the 9999-12-31 records having sequence number > 1. Then use TRAILER3 to write the last record in each group. You can modify it as per your actual field positions and data set attributes.