View previous topic :: View next topic
Author
Message
Mahua Mitra New User Joined: 26 Apr 2007Posts: 49 Location: Delhi
Hi,
I have a file having header and trailer records. My requirement is to sort both the fields. if the header is 'BANK ACCT' then bank account number should be written in the oupu file, and if the 14th-17th position is PREV , then the check number must be in the output file. I need this to be done in a single sort step.
BANK ACCT 001036
CHECK CHECK
NUMBER STATUS ISSUE AMOUNT ACTG DATE PAID DAT
19900000 PREV $4,000.00 6 15 1997
CURR
CNCL $4,000.00 6 15 1997
Thanks in advance,
Mahua
Back to top
William Thompson Global Moderator Joined: 18 Nov 2006Posts: 3156 Location: Tucson AZ
Mahua Mitra wrote:
Code:
BANK ACCT 001036
CHECK CHECK
NUMBER STATUS ISSUE AMOUNT ACTG DATE PAID DAT
19900000 PREV $4,000.00 6 15 1997
CURR
CNCL $4,000.00 6 15 1997
You have given a fine example of your input, how about a fine example of you expected output?
Back to top
Mahua Mitra New User Joined: 26 Apr 2007Posts: 49 Location: Delhi
My ouput must be
001036
19900000
Thanks in advance
Back to top
krisprems Active Member Joined: 27 Nov 2006Posts: 649 Location: India
Mahua Mitra
Here you go
Code:
//*******************************************************
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
BANK ACCT 001036
CHECK CHECK
NUMBER STATUS ISSUE AMOUNT ACTG DATE PAID DAT
19900000 PREV $4,000.00 6 15 1997
CURR
CNCL $4,000.00 6 15 1997
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(1,9,CH,EQ,C'BANK ACCT',OR,18,4,CH,EQ,C'PREV')
OUTREC IFTHEN=(WHEN=(1,9,CH,EQ,C'BANK ACCT'),BUILD=(12,6)),
IFTHEN=(WHEN=(18,4,CH,EQ,C'PREV'),BUILD=(1,8))
/*
SORTOUT
Code:
----+----1
001036
19900000
Back to top
Please enable JavaScript!