View previous topic :: View next topic
|
Author |
Message |
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
Hi All,
I have one input file in which we will be having one header record, some detail records and one trailor record. Details records will contain Add, Delete and Update records. it could be in any order. for ex
Add record
Delete record
Update record
Delete record
Add record
Add record
Update record etc.....
I want to write all these records (including header and trailor records) into one out put file. But the detail records should be in some order as shown below...
Delete record
Add record
Update record.
I want sort this file using JCL.
Please provide me your comments.
Thanks
Simha |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
I want sort this file using JCL. |
What this has to do with COBOL? ? btw which sort product are you using-DFSORT or Syncsort or something else?Which version?
Quote: |
I want to write all these records (including header and trailor records) into one out put file.But the detail records should be in some order |
You need to explain this "some order". And how your header and trailer records look like. Provide some real input and expected output data with all the file attributes. |
|
Back to top |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
I am using DFSORT. I want the records in Delete, Add and Update order. |
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Do you have any field in your file which can diffrentiate it as Add,delete or Update record type?? |
|
Back to top |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
the operation Add, Delete and Update itself will differenciate the each record. Add, Delete or Update will start from location 26. Header record will be identified by using VSP at location 29 and trailor record will be identified by TRAIL at location 31.
Is it possible to use a single file instead of splitting into different files and merge them? |
|
Back to top |
|
|
Ketan Varhade
Active User
Joined: 29 Jun 2009 Posts: 197 Location: Mumbai
|
|
|
|
Hi ,
Please post the thread in related section only to get a quick response.
PLease provide sone more information about the file details so that the record can be identified. There should be some identifier to diffrentiate the records. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Hi Simha,
Below sort step will give you desired result.
I have assumed you have dataset with LRECL 80
Code: |
//S1 EXEC PGM=SORT
//SORTIN DD *
HEADER VSP
ADD RECORD ADD
DELETE RECORD DELETE
UPDATE RECORD UPDATE
DELETE RECORD DELETE
ADD RECORD ADD
ADD RECORD ADD
UPDATE RECORD UPDATE
TRAILER TRAIL
//SORTOUT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(81,1,ZD,A)
INREC IFTHEN=(WHEN=(29,3,CH,EQ,C'VSP'),OVERLAY=(81:C'0')),
IFTHEN=(WHEN=(26,6,CH,EQ,C'DELETE'),OVERLAY=(81:C'1')),
IFTHEN=(WHEN=(26,6,CH,EQ,C'ADD '),OVERLAY=(81:C'2')),
IFTHEN=(WHEN=(26,6,CH,EQ,C'UPDATE'),OVERLAY=(81:C'3')),
IFTHEN=(WHEN=NONE,OVERLAY=(81:C'4'))
OUTFIL BUILD=(1,80)
/*
|
Output will be
Code: |
HEADER VSP
DELETE RECORD DELETE
DELETE RECORD DELETE
ADD RECORD ADD
ADD RECORD ADD
ADD RECORD ADD
UPDATE RECORD UPDATE
UPDATE RECORD UPDATE
TRAILER TRAIL
|
Let us know if you need something else than this.. |
|
Back to top |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
Thanks for your response...LRECL is 350 for my file. When I am using 350 and 351 in place of 80 and 81, i am not getting the expected results. Showing both input file and out put file are same.. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
What is the RECFM of the input file, is it FB or VB
Please post the SYSOUT of your run to show
a) which sort product you are using
b) the release level of the sort product installed |
|
Back to top |
|
|
simha_it
New User
Joined: 05 May 2005 Posts: 30
|
|
|
|
It is working fine. Thank for your timely help..... |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
simha_it,
Another way of doing it without worrying about the LRECL of the file and you need not add any indicators . Using ALTSEQ , we sort the alphabet A records so that it comes just before U.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=Your input file,DISP=SHR
//OUT DD SYSOUT=*
//TOOLIN DD *
DATASORT FROM(IN) TO(OUT) HEADER TRAILER USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(1,1,AQ,A)
ALTSEQ CODE=(C1E3)
//* |
|
|
Back to top |
|
|
|