Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
I have a fixed block file which has a few headers, a number of detail records and a few trailers.
1. The header record has its first two bytes as '10', followed by a timestamp when that header was created.
2. The detail record has its first two bytes as '20'.
3. The trailer record has its first two bytes as '30', followed by a number in the packed decimal format S9(9) Comp-3
4. The number of headers would always be equal to the number of trailers.
I want to build a file out of it that has just the first header present in the given file and just one trailer. In the trailer record that I finally get, the first two bytes, that is '30' should be followed by the sum of numbers present in all the trailer records in the packed decimal format. The detail records should be untouched and should be present in the file without any editing.
Can any one please help me out with this ??? Thanks in advance !
The file looks something like.....
Code:
Command ===> Scroll ===> CSR
****** ***************************** Top of Data *****************************
000001 101999-12-30-23.38.22.113649
000002 205319457130004002 AA NN
000003 209000001360112006 BP YN
000004 206191145740208003 CVM YN
000005 30.....
000006 101999-12-30-23.38.22.329272
000007 205319390000001016 DV NN
000008 209000001360121007 BP YN
000009 206111210000001014 BP YN
000010 30.....
****** **************************** Bottom of Data ***************************
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed for other attributes.
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION EQUALS
* Reformat '30' records to:
* |30|pdfld|data|00000000|pdfld|
INREC IFTHEN=(WHEN=(1,2,CH,EQ,C'30'),
OVERLAY=(81:8C'0',89:3,5)),
* Reformat '10' records to:
* |10|data......|00000000|PD'0'|
IFTHEN=(WHEN=(1,2,CH,EQ,C'10'),
OVERLAY=(81:8C'0',89:X'000000000C')),
* Reformat '20' records to:
* |20|data......|seqnum..|PD'0'|
IFTHEN=(WHEN=NONE,
OVERLAY=(81:SEQNUM,8,ZD,89:X'000000000C'))
* Sort on type and seqnum, and sum on pdfld in 89-93.
* This will give us the first '10' record.
* This will give us all of the '20' records.
* This will give us the first '30' record with the sum of
* the pd fields from all of the '30' records in 89-93.
SORT FIELDS=(1,2,CH,A,81,8,ZD,A)
SUM FIELDS=(89,5,PD)
* For the '30' record, copy the sum of the pd fields
* from 89-93 to 3-7. Set record length to 80.
OUTREC IFOUTLEN=80,
IFTHEN=(WHEN=(1,2,CH,EQ,C'30'),
OVERLAY=(3:89,5))
/*
Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
Hi Frank,
thanks for your reply. Though my file has a record length of 84 but I would adjust that once I hit your solution correctly. Could you please provide me a pointer to some manual/user reference guide on ICEMAN ? I tried to run the solution provided by you but it gave me a few errors like
Code:
SYSIN :
OPTION EQUALS
* REFORMAT '30' RECORDS TO:
*
* |30|PDFLD|DATA|00000000|PDFLD|
*
INREC IF THEN=(WHEN=(1,2,CH,EQ,C'30'),
*
OVERLAY=(81:8C'0',89:3,5)),
*
* REFORMAT '10' RECORDS TO:
*
* |10|DATA......|00000000|PD'0'|
*
IFTHEN=(WHEN=(1,2,CH,EQ,C'10'),
*
OVERLAY=(81:8C'0',89:X'000000000C')),
*
* REFORMAT '20' RECORDS TO:
*
* |20|DATA......|SEQNUM..|PD'0'|
*
IFTHEN=(WHEN=NONE,
*
OVERLAY=(81:SEQNUM,8,ZD,89:X'000000000C'))
*
* SORT ON TYPE AND SEQNUM, AND SUM ON PDFLD IN 89-93.
*
* THIS WILL GIVE US THE FIRST '10' RECORD.
*
* THIS WILL GIVE US ALL OF THE '20' RECORDS.
*
* THIS WILL GIVE US THE FIRST '30' RECORD WITH THE SUM OF
*
* THE PD FIELDS FROM ALL OF THE '30' RECORDS IN 89-93.
*
SORT FIELDS=(1,2,CH,A,81,8,ZD,A)
SUM FIELDS=(89,5,PD)
* FOR THE '30' RECORD, COPY THE SUM OF THE PD FIELDS
*
* FROM 89-93 TO 3-7. SET RECORD LENGTH TO 80.
*
OUTREC IFOUTLEN=80,
*
IFTHEN=(WHEN=(1,2,CH,EQ,C'30'),
OVERLAY=(3:89,5))
/*
*
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER268A INREC STATEMENT : SYNTAX ERROR
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER268A OUTREC STATEMENT : SYNTAX ERROR
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000
The job abended with ABEND0016. Could you please help me out with this ? Providing a link to a ICEMAN tutorial also might be of help. So I can go thru that and figure out the solution.
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
tarunbhardwajleo wrote:
Hi Frank,
thanks for your reply. Though my file has a record length of 84 but I would adjust that once I hit your solution correctly. Could you please provide me a pointer to some manual/user reference guide on ICEMAN ? I tried to run the solution provided by you but it gave me a few errors like
.
.
.
WER268A INREC STATEMENT : SYNTAX ERROR
.
.
.
The job abended with ABEND0016. Could you please help me out with this ? Providing a link to a ICEMAN tutorial also might be of help. So I can go thru that and figure out the solution.
This is Syncsort, and you will need to check a syncsort manual to to do this.
Do you have access to your shops manual?
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
tarunbhardwajleo,
The job I gave you works fine with DFSORT. But the WER messages indicate you're using Syncsort, not DFSORT. I could give you links to the DFSORT books which are available on the web. But since you're using Syncsort, you'll need Syncsort books, not DFSORT books. AFAIK, the Syncsort books are not available on the web.
Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
Hi William,
I have a manual, but it doesnt seem to be descriptive enough.... it has no mention of how to use the IFTHEN clause.... could you please provide me with one ?
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
tarunbhardwajleo wrote:
I have a manual, but it doesnt seem to be descriptive enough.... it has no mention of how to use the IFTHEN clause.... could you please provide me with one ?
Basically, (I think) everything you want to do could be done with Syncsort, Omit duplicate "10" headers, summing duplicate "30" trailers and maintaining current sequence of the data "20" records (though maybe in the same pass?).
My 1.2 Programmer's Guide does some examples of headers and trailers in "How to Use SyncSort?s Data Utility Features". Do you have that manual?
Joined: 23 Feb 2007 Posts: 25 Location: Dallas, TX
Thats right. I want to omit duplicate "10" headers, sum duplicate "30" trailers and maintain current sequence of the data "20" records, all of them in the same pass.
I do not have "How to Use SyncSort?s Data Utility Features". Could you please provide me with the link to that manual ? Thanks in advance !