|
|
| Author |
Message |
rammraju
Active User
Joined: 05 Mar 2005 Posts: 64 Location: Hyderabad
|
|
|
|
Hi all,
My input file looks like
I am trying to prepare a output file which looks the below way
| Code: |
Header
Rec1
Trailer
Header
Rec2
Trailer
Header
Rec3
Trailer
.
. |
The header and trailer needs to repeat for all the records.
Can someone please let me know if it can be done with DFSORT, if so how?
Thanks in advance, |
|
| Back to top |
|
 |
References
|
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 709 Location: Chennai, India
|
|
|
|
Ram,
This can be done using the below DFSORT job.
I have assumed an FB file of LRECL=80. You can modify it as per your file attributes.
| Code: |
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
Rec1
Rec2
Rec3
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(C'Header',/,1,80,/,C'Trailer') |
SORTOUT
| Code: |
Header
Rec1
Trailer
Header
Rec2
Trailer
Header
Rec3
Trailer |
Thanks,
Arun |
|
| Back to top |
|
 |
rammraju
Active User
Joined: 05 Mar 2005 Posts: 64 Location: Hyderabad
|
|
|
|
Thank you very much Arun,
This helps if the Header and Trailer are small (having less characters), what if the Header/Trailer is a record of say 100 characters long and has multiple lines.
Ex:
| Code: |
HeaderLin1.....
HeaderLin2.....
HeaderLin3.....
Rec1.....
TrailerLin1.....
TrailerLin2.....
HeaderLin1.....
HeaderLin2.....
HeaderLin3.....
Rec2.....
TrailerLin1.....
TrailerLin2.....
HeaderLin1.....
HeaderLin2.....
HeaderLin3.....
Rec3.....
TrailerLin1.....
TrailerLin2..... |
|
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4574 Location: San Jose, CA
|
|
|
|
| Quote: |
| what if the Header/Trailer is a record of say 100 characters long and has multiple lines. |
The same technique can be used, but note that the Header and Trailers records CANNOT be longer than the LRECL. If you had Header/Trailer records of 100 characters, the LRECL would have to be at least 100. That said, you could do what you asked about like this:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/100)
//SORTOUT DD DSN=... output file (FB/100)
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(C'HeaderLin1...',/,
C'HeaderLin2...',
C'HeaderLin3...',
1,100,/,
C'TrailerLin1...',/,
C'TrailerLin2...')
|
Of course, with a 100 character string, you need to observe the rules for continuation of literals. You could either code each 100 character string as one literal - for example:
| Code: |
OUTFIL BUILD=(C'H2345678901234567890123456789012345678901234567890123*
45678901234567890123456789012345678901234567890',/,
C'H234567890123456789012345678901234567890123456789012345678901234567*
890123456789012345678901234567890',/,
...
|
with the continuation indicator (*) in column 72.
Or you could break the 100 character string into parts - for example:
| Code: |
OUTFIL BUILD=(C'H2345678901234567890123456789012345678901234567890',
C'12345678901234567890123456789012345678901234567890',/,
C'H23456789012345678901234567890123456789012345678901234567890',
C'1234567890123456789012345678901234567890',/,
...
|
Does that answer your question? |
|
| Back to top |
|
 |
rammraju
Active User
Joined: 05 Mar 2005 Posts: 64 Location: Hyderabad
|
|
|
|
Yes, this answers my question
I am curious to know if it is possible to read the Header and Trailer from two different files and prepare the same output. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4574 Location: San Jose, CA
|
|
|
|
Yes, you can do that by creating DFSORT Symbols for the needed strings that you can use in the OUTFIL BUILD operand.
If you want me to show you how, show an example of the record(s) in the Header file, and the record(s) in the Trailer file and identify the starting position and length of the string(s) you want to use. Also, give the RECFM and LRECL of the Header file, the Trailer file and the Data file. |
|
| Back to top |
|
 |
rammraju
Active User
Joined: 05 Mar 2005 Posts: 64 Location: Hyderabad
|
|
|
|
Here is my requirement
Header file: (LRECL=80,RECFM=FB)
| Code: |
HHHHHHHHHHHHHH......
EEEEEEEEEEEEEE......
AAAAAAAAAAAAAA......
DDDDDDDDDDDDDD...... |
Trailer file: (LRECL=80,RECFM=FB)
| Code: |
TTTTTTTTTTTTTT......
AAAAAAAAAAAAAA......
IIIIIIIIIIIIII......
LLLLLLLLLLLLLL...... |
Data file: (LRECL=80,RECFM=FB)
| Code: |
RECORD1
RECORD2
RECORD3
.
.
. |
The output should look as (LRECL=80,RECFM=80)
| Code: |
HHHHHHHHHHHHHH......
EEEEEEEEEEEEEE......
AAAAAAAAAAAAAA......
DDDDDDDDDDDDDD......
RECORD1
TTTTTTTTTTTTTT......
AAAAAAAAAAAAAA......
IIIIIIIIIIIIII......
LLLLLLLLLLLLLL......
HHHHHHHHHHHHHH......
EEEEEEEEEEEEEE......
AAAAAAAAAAAAAA......
DDDDDDDDDDDDDD......
RECORD2
TTTTTTTTTTTTTT......
AAAAAAAAAAAAAA......
IIIIIIIIIIIIII......
LLLLLLLLLLLLLL......
HHHHHHHHHHHHHH......
EEEEEEEEEEEEEE......
AAAAAAAAAAAAAA......
DDDDDDDDDDDDDD......
RECORD3
TTTTTTTTTTTTTT......
AAAAAAAAAAAAAA......
IIIIIIIIIIIIII......
LLLLLLLLLLLLLL...... |
|
|
| Back to top |
|
 |
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1130 Location: Mumbai - India
|
|
|
|
Techies,
Can SYMNAMES be used for creating DFSORT symbols from more than one input record?
For the above requirement Can we use the input header file and create 4 DFSORT symbols for all the 4 header records in the input file? |
|
| Back to top |
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 709 Location: Chennai, India
|
|
|
|
Ram,
Can you try out this job.
| Code: |
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//C1 DD DSN=&&C1,DISP=(,PASS),DCB=(RECFM=FB,LRECL=80)
//C2 DD DSN=&&C2,DISP=(,PASS),DCB=(RECFM=FB,LRECL=80)
//S1 DD DSN=&&S1,DISP=(,PASS),DCB=(RECFM=FB,LRECL=80)
//S2 DD DSN=&&S2,DISP=(,PASS),DCB=(RECFM=FB,LRECL=80)
//H1 DD DSN=Header.file...................
//H1 DD DSN=Trailer.file..................
//TOOLIN DD *
COPY FROM(H1) USING(CTL1)
COPY FROM(T1) USING(CTL2)
//CTL1CNTL DD *
OPTION COPY
OUTFIL FNAMES=S1,BUILD=(C'H',SEQNUM,2,ZD,C',''',1,73,C'''',80:X)
OUTFIL FNAMES=C1,
IFTHEN=(WHEN=INIT,
BUILD=(16X,C'H',SEQNUM,2,ZD,C',/,',80:X),HIT=NEXT),
IFTHEN=(WHEN=(18,2,ZD,EQ,1),
OVERLAY=(2X,C'OUTFIL BUILD=(',80:X)),REMOVECC,
HEADER1=(2X,C'OPTION COPY'),
TRAILER1=(15X,16:C'1,80,/,')
/*
//CTL2CNTL DD *
OPTION COPY
OUTFIL FNAMES=S2,BUILD=(C'T',SEQNUM,2,ZD,C',''',1,73,C'''',80:X)
OUTFIL FNAMES=C2,
IFTHEN=(WHEN=INIT,
BUILD=(16X,C'T',SEQNUM,2,ZD,C',/,',80:X)),
IFTHEN=(WHEN=(18,2,ZD,EQ,4),
OVERLAY=(20:C') ',80:X))
/*
//STEP2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
// DD DSN=&&S2,DISP=(OLD,PASS)
//SORTIN DD DSN=Input.file............................
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
// DD DSN=&&C2,DISP=(OLD,PASS) |
But this job requires you to give the number of trailer records in CTL2CNTL - IFTHEN=(WHEN=(18,2,ZD,EQ,4). And as the SYMNAMES dataset requires an LRECL of 80,FB, this approach imposes a limit on the header/trailer length you can have.
Frank,
Waiting for your expert solution.....
Thanks,
Arun |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Moderator
Joined: 15 Feb 2005 Posts: 4574 Location: San Jose, CA
|
|
|
|
Ram,
Here's a DFSORT/ICETOOL job that will do what you asked for. Note that since the limit for a symbol constant is 64 characters, we have to break up each 80 character header/trailer line into two symbols of 40 characters each.
| Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//HD DD *
HHHHHHHHHHHHHH......
EEEEEEEEEEEEEE......
AAAAAAAAAAAAAA......
DDDDDDDDDDDDDD......
/*
//TR DD *
TTTTTTTTTTTTTT......
AAAAAAAAAAAAAA......
IIIIIIIIIIIIII......
LLLLLLLLLLLLLL......
/*
//HDSYM DD DSN=&&HS,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TRSYM DD DSN=&&TS,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(HD) USING(CTL1)
COPY FROM(TR) USING(CTL2)
/*
//CTL1CNTL DD *
OUTFIL FNAMES=HDSYM,
BUILD=(C'HA',SEQNUM,1,ZD,C',''',1,40,C'''',80:X,/,
C'HB',SEQNUM,1,ZD,C',''',41,40,C'''')
/*
//CTL2CNTL DD *
OUTFIL FNAMES=TRSYM,
BUILD=(C'TA',SEQNUM,1,ZD,C',''',1,40,C'''',80:X,/,
C'TB',SEQNUM,1,ZD,C',''',41,40,C'''')
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&HS,DISP=(OLD,PASS)
// DD DSN=&&TS,DISP=(OLD,PASS)
//SORTIN DD DSN=... input file (FB/80)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(HA1,HB1,/,HA2,HB2,/,HA3,HB3,/,HA4,HB4,/,
1,80,/,
TA1,TB1,/,TA2,TB2,/,TA3,TB3,/,TA4,TB4)
/*
|
|
|
| Back to top |
|
 |
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1130 Location: Mumbai - India
|
|
|
|
Arun,
| Code: |
| //H1 DD DSN=Trailer.file.................. |
Is that a typo? I guess the DD name should be T1 instead of H1. |
|
| Back to top |
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 709 Location: Chennai, India
|
|
|
|
Aaru,
| Quote: |
| Is that a typo? I guess the DD name should be T1 instead of H1. |
Yes it is............
Thanks,
Arun |
|
| Back to top |
|
 |
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1130 Location: Mumbai - India
|
|
|
|
Arun,
| Quote: |
| Yes it is............ |
Ok. I had pointed it out so that OP is not confused. Else, he would come back saying that the posted JCL is not working. |
|
| Back to top |
|
 |
arcvns
Senior Member
Joined: 17 Oct 2006 Posts: 709 Location: Chennai, India
|
|
|
|
Ram,
Please try the below JCL. I have taken care of the limitations of my previous JCL. You dont need to know the number of header/trailer records
| Code: |
//STEP1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//C1 DD DSN=&&C1,DISP=(MOD,PASS),DCB=(RECFM=FB,LRECL=80)
//C2 DD DSN=&&C2,DISP=(,PASS),DCB=(RECFM=FB,LRECL=80)
//S1 DD DSN=&&S1,DISP=(MOD,PASS),DCB=(RECFM=FB,LRECL=80)
//H1 DD DSN=header-file.............FB,LRECL=80
//T1 DD DSN=trailer-file............FB,LRECL=80
//TOOLIN DD *
COPY FROM(H1) USING(CTL1)
COPY FROM(T1) USING(CTL2)
SPLICE FROM(C2) TO(C1) ON(24,2,ZD) WITH(26,3) WITHALL KEEPNODUPS
//CTL1CNTL DD *
OPTION COPY
OUTFIL FNAMES=S1,
BUILD=(C'HA',SEQNUM,2,ZD,C',''',1,40,C'''',80:X,/,
C'HB',SEQNUM,2,ZD,C',''',41,40,C'''')
OUTFIL FNAMES=C1,IFOUTLEN=80,
IFTHEN=(WHEN=INIT,
BUILD=(16X,C'HA',SEQNUM,2,ZD,
C',HB',SEQNUM,2,ZD,C',/,'),HIT=NEXT),
IFTHEN=(WHEN=(19,2,ZD,EQ,1),
OVERLAY=(2X,C'OUTFIL BUILD=(')),REMOVECC,
HEADER1=(2X,C'OPTION COPY'),
TRAILER1=(16X,C'1,80,/,')
/*
//CTL2CNTL DD *
OPTION COPY
OUTFIL FNAMES=S1,
BUILD=(C'TA',SEQNUM,2,ZD,C',''',1,40,C'''',80:X,/,
C'TB',SEQNUM,2,ZD,C',''',41,40,C'''')
OUTFIL FNAMES=C2,IFOUTLEN=80,
IFTHEN=(WHEN=INIT,
BUILD=(16X,C'TA',SEQNUM,2,ZD,
C',TB',SEQNUM,2,ZD,C',/,')),REMOVECC,
TRAILER1=(23X,COUNT=(M11,LENGTH=2),') ')
/*
//STEP2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=(OLD,PASS)
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
//SORTIN DD DSN=input-file..............FB,LRECL=80 |
Aaru,
I corrected my typo too
Thanks,
Arun |
|
| Back to top |
|
 |
|
|
|