|
View previous topic :: View next topic
|
| Author |
Message |
Iratxe
New User
Joined: 21 Feb 2006 Posts: 24
|
|
|
|
Hello,
I' ve got one file from Lrecl=133 and Recfm=fb with this information:
| Code: |
=COLS> ----+----1----+----2----+----3
000001 GR
000002 1 *
000003 GRAD1
000004 1 AD*
000005 GRAJ3
000006 1 AJPG03
000007 2 AJPXPE
000008 GRAJ5
000009 1 AJPG02
000010 GRJO1
000011 1 JOPHA1
000012 2 JOPHA2
000013 3 JOPHA3
000014 4 JOPHA4
000015 5 JOPHA5
000016 6 JOPHA6
|
and I want this in the output:
| Code: |
=COLS> ----+----1----+----2----+
000001 GR *
000002 GRAD1 AD*
000003 GRAJ3 AJPG03
000004 GRAJ3 AJPXPE
000005 GRAJ5 AJPG02
000006 GRJO1 JOPHA1
000007 GRJO1 JOPHA2
000008 GRJO1 JOPHA3
000009 GRJO1 JOPHA4
000010 GRJO1 JOPHA5
000011 GRJO1 JOPHA6
|
How can I do this?
Thank very much for your dedication,
Iratxe
not everybody can see attachments
edited to inline everything |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Can you please explain the rules for getting shown output. |
|
| Back to top |
|
 |
Iratxe
New User
Joined: 21 Feb 2006 Posts: 24
|
|
|
|
Rules:
Field A: all the GR*
Field B: despreciate what is in position 7 with lentgh=2
Field C: mantein what is from position 11 to the end (*, AD*, etc.)
Field A is diferent from time to time.
Fields B and C are always in the same row.
If we have one field A and one B C, in the output row I want the A and the C in its positions.
If we have one field A but two or more B C below, I want repeat field A with each C as many times as C fields exists.
Is it clear? It´s difficult to explain. Thank you. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Try this sortcard...
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
GR
1 *
GRAD1
1 AD*
GRAJ3
1 AJPG03
2 AJPXPE
GRAJ5
1 AJPG02
GRJO1
1 JOPHA1
2 JOPHA2
3 JOPHA3
4 JOPHA4
5 JOPHA5
6 JOPHA6
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,5,CH,NE,C' '),PUSH=(134:3,5))
OUTFIL OMIT=(3,5,CH,NE,C' '),BUILD=(1,2,3:134,5,X,9,125)
/*
|
Output will be
| Code: |
GR *
GRAD1 AD*
GRAJ3 AJPG03
GRAJ3 AJPXPE
GRAJ5 AJPG02
GRJO1 JOPHA1
GRJO1 JOPHA2
GRJO1 JOPHA3
GRJO1 JOPHA4
GRJO1 JOPHA5
GRJO1 JOPHA6
|
|
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
What are "mantein" and "despreciate". . .?
Using words that are in the dictionary would help someone help you. . . |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Here's another way to do it with DFSORT:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB/133)
//SORTOUT DD DSN=... output file (FB/133)
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(3,5,CH,NE,C' '),
PUSH=(3:3,7,134:SEQ=8))
OUTFIL OMIT=(134,8,ZD,EQ,1),BUILD=(1,134)
/*
|
Sambhaji,
Notice I used only 1 blank in the BEGIN condition rather than 5 as you did.
BEGIN=(3,5,CH,NE,C' '),
DFSORT pads the constant on the right with blanks to the length of the field, so in this case the C' ' will be padded to 5 blanks. This is really handy when you have a large field, e.g. 256 bytes - just code one blank instead of 256 blanks.  |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Quote: |
| DFSORT pads the constant on the right with blanks to the length of the field |
Thanks Frank for enlightening on it.
| Quote: |
| This is really handy when you have a large field, e.g. 256 bytes - just code one blank instead of 256 blanks |
How about any other repetitive character?
It would have been very easy if you could have something like… (1,10,CH,EQ,10C'-') |
|
| Back to top |
|
 |
Iratxe
New User
Joined: 21 Feb 2006 Posts: 24
|
|
|
|
It works fine, thanks very much. It´s great. Now, I´ve found that I´ve got to go further, and, this time it´s more complicated to explain and I´m afraid I can´t do this icetool.
The fact is that I´ve got now one file with this
| Code: |
GRAD1 AD*
E006376 GRAD1
E006287 GRAD1
E006293 GRAD1
E003359 GRAD1
GRAJ3 AJPG03
GRAJ3 AJPXPE
DE06355 GRAJ3
DE11092 GRAJ3
DE10174 GRAJ3
|
the first column begins in position 3rd (Column A), the second begins in 11th (Column B) and the third one in position 19th (Column C).
I need to obtain this:
| Code: |
E006376 GRAD1 AD*
E006287 GRAD1 AD*
E006293 GRAD1 AD*
E003359 GRAD1 AD*
DE06355 GRAJ3 AJPG03
DE11092 GRAJ3 AJPG03
DE10174 GRAJ3 AJPG03
DE06355 GRAJ3 AJPXPE
DE11092 GRAJ3 AJPXPE
DE10174 GRAJ3 AJPXPE
|
I don´t know if it is clear. What I´m trying to do is to repeat Column A as many times as Column B - C says with the information in each case, (first time first information, second time second information and so on).
Is this possible? Thanks very much for your help.
Iratxe |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
| Quote: |
How about any other repetitive character?
It would have been very easy if you could have something like… (1,10,CH,EQ,10C'-') |
Nope. Just pads with blanks for C constant or binary zeros for X constant.
Of course, if you really need 10C'-', you could use INREC OVERLAY to add 10C'-' at the end of the record, compare to that with OUTFIL INCLUDE and then remove it with OUTFIL BUILD. Or you could generate a Symbol using INREC with 10C'-' and use the symbol in INCLUDE. |
|
| Back to top |
|
 |
Escapa
Senior Member

Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
| Frank Yaeger wrote: |
| Quote: |
How about any other repetitive character?
It would have been very easy if you could have something like… (1,10,CH,EQ,10C'-') |
Nope. Just pads with blanks for C constant or binary zeros for X constant.
Of course, if you really need 10C'-', you could use INREC OVERLAY to add 10C'-' at the end of the record, compare to that with OUTFIL INCLUDE and then remove it with OUTFIL BUILD. Or you could generate a Symbol using INREC with 10C'-' and use the symbol in INCLUDE. |
Yeah... I have seen couple of examples by you using symbol at this forum. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Iratxe,
Does the order of records matter? If not use this DFSORT JCL which will give you the desired results
| Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=your input fb 133 file,DISP=SHR
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(19,1,CH,NE,C' '),
PUSH=(134:19,16)),
IFTHEN=(WHEN=INIT,OVERLAY=(150:SEQNUM,8,ZD,RESTART=(134,8))),
IFTHEN=(WHEN=GROUP,BEGIN=(150,8,ZD,EQ,1),PUSH=(158:142,8))
OUTFIL IFOUTLEN=133,OMIT=(19,1,CH,NE,C' '),
IFTHEN=(WHEN=(142,8,CH,EQ,158,8,CH),OVERLAY=(11:134,16)),
IFTHEN=(WHEN=(142,8,CH,NE,158,8,CH),
BUILD=(1,10,134,16,35,107,/,1,10,134,8,158,8,35,107))
//* |
The output from this job is
| Code: |
E006376 GRAD1 AD*
E006287 GRAD1 AD*
E006293 GRAD1 AD*
E003359 GRAD1 AD*
DE06355 GRAJ3 AJPXPE
DE06355 GRAJ3 AJPG03
DE11092 GRAJ3 AJPXPE
DE11092 GRAJ3 AJPG03
DE10174 GRAJ3 AJPXPE
DE10174 GRAJ3 AJPG03
|
If you really want the order as you shown you can this output as another pass and sort it on 11, 16,ch,a which will give you the desired results |
|
| Back to top |
|
 |
Iratxe
New User
Joined: 21 Feb 2006 Posts: 24
|
|
|
|
It´s great!!
Thank you very very much. It runs perfectly. The order is not very important because I can always order the result.
Thank you all!
Iratxe |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|