|
View previous topic :: View next topic
|
| Author |
Message |
ragbose
New User
Joined: 11 Jan 2010 Posts: 13 Location: chennai/hyderabad
|
|
|
|
Hi,
I have one question,If some gets some time please help..
1st Example:
I have an input file namely EMP-IN & output EMP-OUT which is (FB, LRECL=80) respectively
EMP-IN
----------------------------------------------------
ESUOHG ENAID
OTLA NELLA
----------------------------------------------------
I want the above Input as below output
EMP-OUT
-----------------------------------------------------
ALLEN ALTO
DIANE GHOUSE
-----------------------------------------------------
Condition :
Last letter of the input file is getting reserved to 1st letter in the output file..(i.e OTLA NELLA (input) to ALLEN ALTO(output). Similary till the end of the string..
Can we do this using DFSORT?
I am referring to the DFSORT material to findout.. Meanwhile if possible help me out..
Thank you so much for the help |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Raghu,
here is one way of doing this
| Code: |
//SORT0001 EXEC PGM=SORT
//SORTIN DD *
ESUOHG ENAID
OTLA NELLA
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(81:80,1,79,1,78,1,77,1,76,1,75,1,74,1,73,1,72,1,71,1,
70,1,69,1,68,1,67,1,66,1,65,1,64,1,63,1,62,1,61,1,
60,1,59,1,58,1,57,1,56,1,55,1,54,1,53,1,52,1,51,1,
50,1,49,1,48,1,47,1,46,1,45,1,44,1,43,1,42,1,41,1,
40,1,39,1,38,1,37,1,36,1,35,1,34,1,33,1,32,1,31,1,
30,1,29,1,28,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1,
20,1,19,1,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,1,
10,1,09,1,08,1,07,1,06,1,05,1,04,1,03,1,02,1,01,1)
OUTREC BUILD=(81,80,JFY=(SHIFT=LEFT))
/*
|
Gerry |
|
| Back to top |
|
 |
ragbose
New User
Joined: 11 Jan 2010 Posts: 13 Location: chennai/hyderabad
|
|
|
|
Hi Greey,
Thank you very much.
The JCL provided by you is working very fine.. But I am sorry if my requirement is not clear to you..
If you see the input file
EMP-IN
----------------------------------------------------
ESUOHG ENAID
OTLA NELLA
----------------------------------------------------
And I wanted the output file as
-----------------------------
ALLEN ALTO - this was the last record in the input file
DIANE GHOUSE - First record of the input file
---------------------------
So The jcl shoudl reverse the letter as well as the Last record should come as 1st record in the output and next last record should be 2nd and so on till EOF.
Once again I am sorry if i am not clear with the explanation.
Thanks for spending time and helping us |
|
| Back to top |
|
 |
nigelosberry
New User

Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
Once you have done what gcicchet suggested you could write another SORT step in the job with something like:
| Code: |
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(81,8,ZD,D)
OUTREC BUILD=(1,80) |
The output dataset after this should have the records written in your desired order. |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1217 Location: Dublin, Ireland
|
|
|
|
Or even, in a single step as:
| Code: |
//SORT0001 EXEC PGM=SORT
//SORTIN DD *
ESUOHG ENAID
OTLA NELLA
/*
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
INREC OVERLAY=(81:80,1,79,1,78,1,77,1,76,1,75,1,74,1,73,1,72,1,71,1
70,1,69,1,68,1,67,1,66,1,65,1,64,1,63,1,62,1,61,1
60,1,59,1,58,1,57,1,56,1,55,1,54,1,53,1,52,1,51,1
50,1,49,1,48,1,47,1,46,1,45,1,44,1,43,1,42,1,41,1
40,1,39,1,38,1,37,1,36,1,35,1,34,1,33,1,32,1,31,1
30,1,29,1,28,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1
20,1,19,1,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,1
10,1,09,1,08,1,07,1,06,1,05,1,04,1,03,1,02,1,01,1
SEQNUM,8,ZD)
SORT FIELDS=(161,8,ZD,D)
OUTREC BUILD=(81,80,JFY=(SHIFT=LEFT))
/* |
Garry. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Garry Carroll,
You are missing a comma at the end on your INREC statement. I would suggest using a BUILD rather than an overlay.
| Code: |
//SYSIN DD *
INREC BUILD=(80,1,79,1,78,1,77,1,76,1,75,1,74,1,73,1,72,1,71,1,
70,1,69,1,68,1,67,1,66,1,65,1,64,1,63,1,62,1,61,1,
60,1,59,1,58,1,57,1,56,1,55,1,54,1,53,1,52,1,51,1,
50,1,49,1,48,1,47,1,46,1,45,1,44,1,43,1,42,1,41,1,
40,1,39,1,38,1,37,1,36,1,35,1,34,1,33,1,32,1,31,1,
30,1,29,1,28,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1,
20,1,19,1,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,1,
10,1,09,1,08,1,07,1,06,1,05,1,04,1,03,1,02,1,01,1,
SEQNUM,8,ZD)
SORT FIELDS=(81,8,ZD,D)
OUTREC BUILD=(1,80,JFY=(SHIFT=LEFT))
//* |
|
|
| Back to top |
|
 |
ragbose
New User
Joined: 11 Jan 2010 Posts: 13 Location: chennai/hyderabad
|
|
|
|
Hi,
Thanks a lot,
I have one doubt/question..Why do we give (SORT FIELDS=(81,8,ZD,D)) 81 position as the file is having only LRECL as 80? Any reason? always I seen them in Overlay as well INREC OVERLAY=(81:SEQNUM,8,ZD))
Sorry if this question is silly.. bt wanted to know..
Thanks Skolusu.. Even i corrected when i use that JCL given by Greey,
I have found one more way to copy the records, Hope it helps some one
JCL Used:
//SORT001 EXEC PGM=SORT
//SORTIN DD DSN=INPUT-FILE,DISP=SHR
//SORTOUT DD DSN=&&TEMP,DISP=(,PASS)
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(81:80,1,79,1,78,1,77,1,76,1,75,1,74,1,73,1,72,1,71,1,
70,1,69,1,68,1,67,1,66,1,65,1,64,1,63,1,62,1,61,1,
60,1,59,1,58,1,57,1,56,1,55,1,54,1,53,1,52,1,51,1,
50,1,49,1,48,1,47,1,46,1,45,1,44,1,43,1,42,1,41,1,
40,1,39,1,38,1,37,1,36,1,35,1,34,1,33,1,32,1,31,1,
30,1,29,1,28,1,27,1,26,1,25,1,24,1,23,1,22,1,21,1,
20,1,19,1,18,1,17,1,16,1,15,1,14,1,13,1,12,1,11,1,
10,1,09,1,08,1,07,1,06,1,05,1,04,1,03,1,02,1,01,1)
OUTREC BUILD=(81,80,JFY=(SHIFT=LEFT))
/*
//STEP002 EXEC PGM=FILEAID
//DD01 DD DSN=&&TEMP,DISP=SHR
//DD01O DD SYSOUT=*
//SYSIN DD *
$$DD01 COPYBACK OUT=2
//SYSPRINT DD SYSOUT=*
Thanks every one... once again.. you are really helping us!!
EMP-IN
----------------------------------------------------
ESUOHG ENAID
OTLA NELLA
----------------------------------------------------
EMP-OUT
-----------------------------
ALLEN ALTO
DIANE GHOUSE
--------------------------- |
|
| Back to top |
|
 |
nigelosberry
New User

Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
| ragbose wrote: |
Why do we give (SORT FIELDS=(81,8,ZD,D)) 81 position as the file is having only LRECL as 80? Any reason? always I seen them in Overlay as well INREC OVERLAY=(81:SEQNUM,8,ZD))
|
This means that the sort utility writes an 8 byte sequence number at position 81 of the output record. Your file has lrecl=80 but sort workspace has more.
This 8 byte sequence number is nothing but a number nnnnnnnn in Zoned Decimal format. Once sort has added sequence number to all the records, this sequence number can then be used for sorting the dataset in an order based on this very sequence number.
Try OVERLAY=(71:SEQNUM,8,ZD) with the same file and see what's the output. You will get a better understanding of this. |
|
| Back to top |
|
 |
nigelosberry
New User

Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
| ragbose wrote: |
| Code: |
//STEP002 EXEC PGM=FILEAID
//DD01 DD DSN=&&TEMP,DISP=SHR
//DD01O DD SYSOUT=*
//SYSIN DD *
$$DD01 COPYBACK OUT=2
//SYSPRINT DD SYSOUT=* |
|
This is FileAid called from batch. Depends on whether an installation has File-Aid.
Why to break a simple task in 2 steps and both the steps have different utilities running!! As Garry said, the overall thing can be done in a single step. And I feel that will be better from a maintenance point of view. |
|
| Back to top |
|
 |
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1217 Location: Dublin, Ireland
|
|
|
|
Kolusu wrote:
| Quote: |
Garry Carroll,
You are missing a comma at the end on your INREC statement. I would suggest using a BUILD rather than an overlay.
|
My bad - cut & paste error. I take your point about BUILD rather than OVERLAY. thanks.
Garry. |
|
| Back to top |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
| ragbose wrote: |
I have found one more way to copy the records, Hope it helps some one
|
I don't think it is going to be of any help to anyone when your file-aid control cards are limiting the output to just 2 records. what happens if your input has more than 2 records like this? Are you going to change the control cards every time you have variable number of records?
| Code: |
//SORTIN DD *
ESUOHG ENAID
OTLA NELLA
ESOBGAR
REGEAY KNARF
TROSFD
MBI
|
On the other hand I don't see a need/reason to use another utility to read the file once again when you can do everything you want in a single pass of data. |
|
| Back to top |
|
 |
ragbose
New User
Joined: 11 Jan 2010 Posts: 13 Location: chennai/hyderabad
|
|
|
|
Hi All,
Ya Skolusu You are correct..I checked the forum once after I got the other way to copy the record from back... So I posted the solution I used to satisfy the requirement and later Once I see your solution I incorporated according to you..
Sorry for the confusion.
Thanks each and every one for helping. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|