Hi All,
I have a trouble during sorting. I can sort all records except the header. because my header record didn't have
sort key. does anybody have good idea for that first copy the header record and then sorting the others records.
my sort production is Syncsort for Z/os.
thanks.
how to copy header record during sorting.
-
- Posts: 19
- Joined: Mon Jul 06, 2009 4:35 pm
- Skillset: JCL, COBOL, VSAM, DB2, SUPRA, CICS
- Referer: Browsing
Re: how to copy header record during sorting.
STEP010: First break the file into two files using STOPAFT = 1 for the header and SKIPREC = 1 to capture the records without header. Remember to use SORT FIELDS = COPY.
STEP020: Now sort the second file containing only the records acc. to your requirements.
STEP030: Next combine the two files into a single file. For this you can use REPRO and give the two files as the SORTIN DD statement. In the control card use SORT FIELDS = COPY.
STEP020: Now sort the second file containing only the records acc. to your requirements.
STEP030: Next combine the two files into a single file. For this you can use REPRO and give the two files as the SORTIN DD statement. In the control card use SORT FIELDS = COPY.
- arcvns
- Posts: 55
- Joined: Sat Feb 28, 2009 12:36 am
- Skillset: COBOL, JCL, SYNCSORT, VSAM, DB2
- Referer: Nobody
- Location: India
- Contact:
Re: how to copy header record during sorting.
Hello,
Here's a one-step SyncSort job which does exactly what you asked. This is just a sample, you can easily modify it as per your requirement.
Let me know if you come across any issues.SORTOUT
Here's a one-step SyncSort job which does exactly what you asked. This is just a sample, you can easily modify it as per your requirement.
Let me know if you come across any issues.
Code: Select all
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
HEADER
KEY-A
KEY-C
KEY-D
KEY-B
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,C'1')),
IFTHEN=(WHEN=(81,8,ZD,EQ,1),OVERLAY=(89:C'0'))
SORT FIELDS=(89,1,CH,A,1,5,CH,A)
OUTFIL BUILD=(1,80)
Code: Select all
HEADER
KEY-A
KEY-B
KEY-C
KEY-D
Arun
-
- Posts: 279
- Joined: Fri Jul 18, 2008 7:46 pm
- Skillset: JCL,COBOL,DB2,IMS/DB,CICS,VSAM
- Referer: I was banned by superk in main forum so I am here
Re: how to copy header record during sorting.
Arun, what a cool trick this is.......
Very nice.

Re: how to copy header record during sorting.
thanks all of you.
it works well right now. but there is
a little bit problem. my input record is VB. althougn I
got the output dataset. but the header record is
extended to 2004. Could you tell me how to keep the same
size as before sorting for the header record. thanks.
it works well right now. but there is
a little bit problem. my input record is VB. althougn I
got the output dataset. but the header record is
extended to 2004. Could you tell me how to keep the same
size as before sorting for the header record. thanks.
Code: Select all
026900 //SYSIN DD *
026910 INREC IFTHEN=(WHEN=(6,5,ZD,EQ,12251),
026920 OVERLAY=(249:C'0',2004:C'0'))
027000 SORT FIELDS=(40,10,CH,A,
027100 11,8,CH,A,
027200 249,2,BI,A)
027210 //* SKIPREC=1
027300 /*
- dick scherrer
- Global moderator
- Posts: 6268
- Joined: Sat Jun 09, 2007 8:58 am
Re: how to copy header record during sorting.
Hello,
You might consider placing the seqnum at the beginning of the records instead of the end. . .
You might consider placing the seqnum at the beginning of the records instead of the end. . .
Hope this helps,
d.sch.
d.sch.
Re: how to copy header record during sorting.
thanks, dick
maybe I didn't describe the problem clear. the input dataset have 3 sort key(offset is 40,11 and 249).
all input record have the 3 sort key except header(just 2 sort key, because header's size is 166).
when I run the JCL, got the error message:" control field exceed size". that's why I have to extend
the header record size before sorting.
maybe I didn't describe the problem clear. the input dataset have 3 sort key(offset is 40,11 and 249).
all input record have the 3 sort key except header(just 2 sort key, because header's size is 166).
when I run the JCL, got the error message:" control field exceed size". that's why I have to extend
the header record size before sorting.
-
- Global moderator
- Posts: 369
- Joined: Tue Feb 26, 2008 11:15 pm
- Skillset: Syncsort MFX for z/OS
- Referer: Dick Scherrer
- Location: USA
- Contact:
Re: how to copy header record during sorting.
Helen2000,
Do you want the header record to remain as the first record, or to be sorted along with all the data records?
Do you want the header record to remain as the first record, or to be sorted along with all the data records?
- arcvns
- Posts: 55
- Joined: Sat Feb 28, 2009 12:36 am
- Skillset: COBOL, JCL, SYNCSORT, VSAM, DB2
- Referer: Nobody
- Location: India
- Contact:
Re: how to copy header record during sorting.
helen2000,
A few more questions apart from what Alissa has asked.
Does "(6,5,ZD,EQ,12251)" identify your header record?
What is your input LRECL?
A few more questions apart from what Alissa has asked.
Does "(6,5,ZD,EQ,12251)" identify your header record?
What is your input LRECL?
Arun
-
- Posts: 19
- Joined: Mon Jul 06, 2009 4:35 pm
- Skillset: JCL, COBOL, VSAM, DB2, SUPRA, CICS
- Referer: Browsing
Re: how to copy header record during sorting.
You could convert from variable format to fixed format.
-
- Similar Topics
- Replies
- Views
- Last post
-
-
Copy partial record after a string in a record using SORT.
by Esmayeelhusen » Thu May 04, 2023 3:03 pm » in DFSORT/ICETOOL/ICEGENER - 16
- 4223
-
by Esmayeelhusen
View the latest post
Mon May 22, 2023 3:50 pm
-
-
-
Can i read output file created after SORTing in the same pgm
by savitha_y » Sat Feb 06, 2021 1:17 am » in IBM Cobol - 4
- 1615
-
by savitha_y
View the latest post
Tue Feb 09, 2021 7:11 pm
-
-
- 1
- 1249
-
by willy jensen
View the latest post
Sat Sep 04, 2021 12:51 am
-
- 12
- 3890
-
by RalphEagle
View the latest post
Fri Jul 30, 2021 1:00 pm
-
- 4
- 6170
-
by steve-myers
View the latest post
Sat May 15, 2021 1:58 am