View previous topic :: View next topic
|
Author |
Message |
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
I have few headers and detail records of that header:
for ex:
currently:
i have 10 records in detail
then i have the header
then i have 5 records in details
then i have a header
I want just reverse like:
1st header should come
then 10 detail records of the header
then 2nd header
then 5 detail records of the header
How to do this thru SORT utility?
please let me know. Thanks in advance
Thanks |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Unless you can be bothered to give us some useful information it would appear that you will not do this using sort.
Because the solution for sort related questions may vary from product to product, please ensure that you state clearly which sort product you are using.
If you are not sure, then by running a simple sort step shown below, you will be able to find out for yourself.
If the messages start with ICE then your product is DFSORT and will be moved by a moderator. Please also post the output of the complete line which has a message code ICE201I, as this will enable our DFSORT experts to determine which release of DFSORT that you have installed. This may also affect the solution offered.
If the messages start with WER or SYT then the product is SYNCSORT and the topic will remain in the JCL forum by one of the moderators. Please also post the information telling which version of SYNCSORT is installed, as this may also affect the solution offered.
Thank you for taking your time to ensure that the valuable time of others is not wasted by offering inappropriate solutions which are not relevant due to the sort product being used and/or the release that is installed in your site.
Code: |
//SORTSTEP EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
ABC
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY |
You also need to provide more detail than you already have.
What is the DSORG, RECFM & LRECL of the file
How do you distinguish a header record from a data record |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Do you have something in your data by which you can identify the header/detail records? Post some sample data and expected output using Code tag, input RECFM/LRECL and the sort product/release info |
|
Back to top |
|
|
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
What is the DSORG, RECFM & LRECL of the file
DSORG=PS
RECFM=FB
LRECL= 512
How do you distinguish a header record from a data record:
All the Header starting with DIVHDR----------
If you need any other information please let me know..
Thanks |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
And have we found out which sort product and its release level is installed yet, as indicated in my original post.
Please remember that we do not ask for information just for fun, but because there is a reason. So please supply the required information rather than have another forum member waste time on a solution that is not appropriate for your product / release. |
|
Back to top |
|
|
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
I am using DFSORT and the message line in the spool is:
ICE201I F RECORD TYPE IS F - DATA STARTS IN POSITION 1
If you need any more information .. let me know..
Thanks |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Below sortstep will give you desired result...
Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
D1234561
D1234562
D1234563
D1234564
DIVHDR1---------
D1234571
D1234572
D1234573
D1234574
DIVHDR2---------
D1234581
D1234582
D1234583
DIVHDR3---------
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
OPTION EQUALS
SORT FIELDS=(513,8,ZD,A,521,1,CH,A)
INREC IFTHEN=(WHEN=GROUP,END=(1,6,CH,EQ,C'DIVHDR'),PUSH=(513:ID=8)),
IFTHEN=(WHEN=(1,6,CH,EQ,C'DIVHDR'),OVERLAY=(521:C'0')),
IFTHEN=(WHEN=NONE,OVERLAY=(521:C'1'))
OUTFIL BUILD=(1,512)
/*
|
Output will be
Code: |
DIVHDR1---------
D1234561
D1234562
D1234563
D1234564
DIVHDR2---------
D1234571
D1234572
D1234573
D1234574
DIVHDR3---------
D1234581
D1234582
D1234583
|
There could be easier solution possible if there is any identifier for detail records.
Since you have not shown sample records, couldn't do anything. |
|
Back to top |
|
|
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
Hi,
Thanks a lot for the information.
can you please why this SORT FIELDS=(513,8,ZD,A,521,1,CH,A) is used here. |
|
Back to top |
|
|
Ajay Baghel
Active User
Joined: 25 Apr 2007 Posts: 206 Location: Bangalore
|
|
|
|
Hi Maxsubrat,
WHEN=GROUP,END=(1,6,CH,EQ,C'DIVHDR'),PUSH=(513:ID=8)),
--> This is putting a counter of 8 digits in position 513 on each record till it finds a record having 'DIVHDR' in col 1-6
So,
D1234561 00000000
D1234562 00000000
D1234563 00000000
D1234564 00000000
DIVHDR1--------- 00000000
D1234571 00000001
D1234572 00000001
D1234573 00000001
D1234574 00000001
DIVHDR2--------- 00000001
D1234581 00000002
D1234582 00000002
D1234583 00000002
DIVHDR3--------- 00000002
WHEN=(1,6,CH,EQ,C'DIVHDR'),OVERLAY=(521:C'0')),
This then, puts '0' in col 521 in every record which has 'DIVHDR' in col1-6
So, it becomes
D1234561 00000000
D1234562 00000000
D1234563 00000000
D1234564 00000000
DIVHDR1--------- 000000000
D1234571 00000001
D1234572 00000001
D1234573 00000001
D1234574 00000001
DIVHDR2--------- 000000010
D1234581 00000002
D1234582 00000002
D1234583 00000002
DIVHDR3--------- 000000020
IFTHEN=(WHEN=NONE,OVERLAY=(521:C'1'))
This puts '1' in col 521 in remaining records
D1234561 000000001
D1234562 000000001
D1234563 000000001
D1234564 000000001
DIVHDR1--------- 000000000
D1234571 000000011
D1234572 000000011
D1234573 000000011
D1234574 000000011
DIVHDR2--------- 000000010
D1234581 000000021
D1234582 000000021
D1234583 000000021
DIVHDR3--------- 000000020
SORT FIELDS=(513,8,ZD,A,521,1,CH,A) then sorts the abaove first on data in col 513 to 520 and then on 521 (both ascending order)
DIVHDR1--------- 000000000
D1234561 000000001
D1234562 000000001
D1234563 000000001
D1234564 000000001
DIVHDR2--------- 000000010
D1234571 000000011
D1234572 000000011
D1234573 000000011
D1234574 000000011
DIVHDR3--------- 000000020
D1234581 000000021
D1234582 000000021
D1234583 000000021
OUTFIL BUILD=(1,512)
it causes to take data only in first 512 bytes
DIVHDR1---------
D1234561
D1234562
D1234563
D1234564
DIVHDR2---------
D1234571
D1234572
D1234573
D1234574
DIVHDR3---------
D1234581
D1234582
D1234583
Sambhaji,
Plz correct me if i am wrong.
Thanks
Ajay |
|
Back to top |
|
|
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
Hi,
Thanks for the reply.
When i use this sort some of the rows are getting misplaced.Like the 5th row is coming to 2nd row.Because of this the content is getting changed.
Example:
Input:
----------------
F1F120ABCDEF
F1ZZ30ABCDEF
M1M120GHIJKL
M1ZZ30GHIJKL
F1F120RSTUVW
F1ZZ30RSTUVW
Output:
---------------
F1F120ABCDEF
F1F120RSTUVW
F1ZZ30ABCDEF
M1M120GHIJKL
M1ZZ30GHIJKL
F1ZZ30RSTUVW
See here the data has changed.
Can you please let me know why this is hapening and how to resolve this issue. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
All the Header starting with DIVHDR---------- |
no trace of header records in Your sample! |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
maxsubrat,
Try adding:
I suspect Escapa has it as the default so doesn't realize it's needed. |
|
Back to top |
|
|
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
Hi,
Hi,
Thanks for the reply.
When i use this sort some of the rows are getting misplaced.Like the 5th row is coming to 2nd row.Because of this the content is getting changed.
Example:
Input:
----------------
F1F120ABCDEF
F1ZZ30ABCDEF
M1M120GHIJKL
M1ZZ30GHIJKL
F1F120RSTUVW
F1ZZ30RSTUVW
DIVHDRB1109
Output:
---------------
DIVHDRB1109
F1F120ABCDEF
F1F120RSTUVW
F1ZZ30ABCDEF
M1M120GHIJKL
M1ZZ30GHIJKL
F1ZZ30RSTUVW
See here the data has changed.
Can you please let me know why this is hapening and how to resolve this issue. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you post the exact jcl (change/remove the dsns if necessary) and control statements you submitted along with the informational messages (including message ids) generated by the problem run. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
maxsubrat,
Did you try using:
in //SYSIN as I suggested in my previous post? |
|
Back to top |
|
|
maxsubrat
Active User
Joined: 27 Feb 2008 Posts: 110 Location: india
|
|
|
|
Thanks a lot..
It worked by ading OPTION EQUALS |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Good. I've added OPTION EQUALS to Escapa's job to avoid confusion for future readers. |
|
Back to top |
|
|
|