|
View previous topic :: View next topic
|
| Author |
Message |
itsurfrank
New User
.jpg)
Joined: 31 Aug 2009 Posts: 6 Location: India
|
|
|
|
Could you please help me to do this...
i/P File.. :
A,B,C
1
1
1
2
2
2
3
3
3
o/p File :
A
1
2
3
B
1
2
3
C
1
2
3
Thanks in Advance... |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
It's not at all clear what you want to do.
You need to explain the rules for getting from that input to that output.
Is that the way the actual input and output records look? What is the pattern of the input records - does it repeat?
Give the RECFM and LRECL of the input file. Give the starting position, length and format of the relevant fields. |
|
| Back to top |
|
 |
itsurfrank
New User
.jpg)
Joined: 31 Aug 2009 Posts: 6 Location: India
|
|
|
|
Thanks for your quick response Frank !!!
1. Yes Frank each record will be repeated based on the number of headers(here it is A B C)
2. No keys just duplicates
3. RECFM = FB
LRECL = 80
Input File :
A B C
111111111
111111111
111111111
2222222
2222222
2222222
33333
33333
33333
o/p File :
A
111111111
2222222
33333
B
111111111
2222222
33333
C
111111111
2222222
33333
Logic to be implemented:
Actually , the input file will have the header's in the first row of the file.The details record are in such a way that if there is 3 header, then each record will be duplicated 3 time.(as above)
My requirement is to split this input file into 3 blocks as we have 3 headers.Every block will be same (as every records will be available in every block)
Expecting your kind response !!! Hope u ll help me in this regards,
Thanks,
Frank.G |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
| The details record are in such a way that if there is 3 header, then each record will be duplicated 3 time. |
And if there are 4 headers, then each record will be duplicated 4 times? And so on? Or is there always just 3 headers?
The records with the headers is always the FIRST record?
What is the maximum number of headers? Is the length of each header really 1 byte? If not, what does the header record really look like? How do we identify one header from the next (specific positions, a delimiter, something else)? |
|
| Back to top |
|
 |
itsurfrank
New User
.jpg)
Joined: 31 Aug 2009 Posts: 6 Location: India
|
|
|
|
Hi,
Please find below my answers for your query.
And if there are 4 headers, then each record will be duplicated 4 times?
Exactly ... Frank.
Is there always just 3 headers?
No.Header will be maximum of 10.The duplication of record is based upon the header.i.e if n headers then n time the records are duplicated.
The records with the headers is always the FIRST record?
Yes.
What is the maximum number of headers?
10 headers.
Is the length of each header really 1 byte?
No.
If not, what does the header record really look like?
8 bytes . ( eg : MEM0FOI0)
How do we identify one header from the next (specific positions, a delimiter, something else)?
delimiter is used Frank. Its comma (MEM0FOI0,MEM0FOI1,MEM0FOI2...)
Sorry for the inconvienece made !!
Hope i have answered you clearly !!! let me know if u want more clarifcation ...
Thanks,
Frank.G. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Before I spend time on this, I want to make sure I understand what you want.
You show the example header record as:
MEM0FOI0,MEM0FOI1,MEM0FOI2
where each header is 8 bytes. This looks like fixed positions (first header in 1-8, second header in 10-17, etc).
But is it really comma delimited where a header can be 1-8 bytes, for example,
MEM0,B,MEM0FOI2
I need to know exactly what the first record can look like in order to show you how to do this correctly. |
|
| Back to top |
|
 |
itsurfrank
New User
.jpg)
Joined: 31 Aug 2009 Posts: 6 Location: India
|
|
|
|
Frank,
In technical terms its mailbox id(MEM0FOI0).It will be always 8 bytes of length.
1------8,10-----17,19------26 and soon.
Thanks,
Frank. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
itsurfrank,
You can only have 9 headers within a LRECL of 80 as you have a delimiter between each header value.
The following DFSORT JCL will give you the desired results.
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=Your input FB 80 byte lrecl file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(101:1,80)),
IFTHEN=(WHEN=INIT,OVERLAY=(90:SEQNUM,8,ZD,RESTART=(1,80))),
IFTHEN=(WHEN=GROUP,BEGIN=(90,8,ZD,EQ,1),PUSH=(81:ID=8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,2),OVERLAY=(90:101,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,3),OVERLAY=(90:110,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,4),OVERLAY=(90:119,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,5),OVERLAY=(90:128,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,6),OVERLAY=(90:137,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,7),OVERLAY=(90:146,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,8),OVERLAY=(90:155,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,9),OVERLAY=(90:164,8)),
IFTHEN=(WHEN=(81,8,ZD,EQ,10),OVERLAY=(90:173,8))
OUTFIL STARTREC=2,BUILD=(1,80),
REMOVECC,SECTIONS=(90,8,HEADER3=(90,8))
//* |
|
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Hi Kolusu,
I know you do test your solutions before posting and it may be due to my lack of subject knowledge.
Here the expected output record order is different from that of the input. Will the above solution with SORT FIELDS=COPY take care of this? |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Arun Raj,
Oops Sorry. I didn't notice that OP wanted the output also sorted. For some reason I thought he just wanted to Push the header on to the duplicated rows. My bad. Thanks for pointing it out.
Here are the updated control cards which would give him the desired results.
| Code: |
//SYSIN DD *
SORT FIELDS=(90,8,CH,A),EQUALS
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD)),
IFTHEN=(WHEN=GROUP,BEGIN=(81,8,ZD,EQ,1),PUSH=(101:1,80)),
IFTHEN=(WHEN=INIT,OVERLAY=(90:SEQNUM,8,ZD,RESTART=(1,80)))
OUTREC IFTHEN=(WHEN=(90,8,ZD,EQ,1),OVERLAY=(81:101,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,2),OVERLAY=(81:110,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,3),OVERLAY=(81:119,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,4),OVERLAY=(81:128,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,5),OVERLAY=(81:137,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,6),OVERLAY=(81:146,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,7),OVERLAY=(81:155,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,8),OVERLAY=(81:164,8)),
IFTHEN=(WHEN=(90,8,ZD,EQ,9),OVERLAY=(81:173,8))
OUTFIL STARTREC=2,BUILD=(1,80),
REMOVECC,SECTIONS=(90,8,HEADER3=(81,8))
//* |
|
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Skolusu wrote: |
| Thanks for pointing it out. |
It happens at times. You're welcome  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|