Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DFSORT for a variable length file with few constraints.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
kranti

New User


Joined: 10 Oct 2005
Posts: 27

PostPosted: Mon Oct 17, 2005 1:33 pm    Post subject: DFSORT for a variable length file with few constraints.
Reply with quote

Hi ,

I have some problem in sorting a file using DFSORT.Scenario is like,
I have to sort a file based on some reference number.But actual file is variable length format and the file format is like

HEADER RECORD (20 BYTES)
DETAIL RECORD (100 BYTES)
DETAIL RECORD (100 BYTES)
DETAIL RECORD (100 BYTES)
DETAIL RECORD (100 BYTES)
TRAILER RECORD (20 BYTES)

We want to sort the detail records based on some reference number with an offset of (50 : 10) in detail record. Here we want to skip the both header and trailer records.
Can we handle this total process in a one DFSORT step?

Could u anybody please suggest the solution.

Thanks in advance,
Kran.
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Mon Oct 17, 2005 2:27 pm    Post subject: Re: DFSORT for a variable length file with few constraints.
Reply with quote

Hi Kranti,

If I interpreted correctly, you want to SORT your VB Input File with skippping Header & trailer Record on basis of field starting from column number 50 up to length of 10 chars.

Here you have not mentioned, that field is of what type ? also REC Length of the Input File....

Code:
//S001     EXEC SORT                     
//SYSPRINT DD SYSOUT=*                   
//SYSOUT   DD SYSOUT=*                   
//SORTIN   DD DSN=USERID.RECORDS.VB,DISP=SHR     
//SORTOUT  DD DSN=USERID.RECORDS.VB.OUT,
//         DISP=(,CATLG,DELETE)
//         SPACE...RECFM...LRECL
//SYSIN    DD *                           
  SORT FIELDS=(54,10,CH,A),               
  SKIPREC=1,                             
  STOPAFT=N                               
/*               

Here you need to include proper SPACE PARM along with RECFM & LRECL.....

N is total number of recs (including header +trailer) - 2.

Or you'll have to wait up to Frank on-lines...for the panacea.....

Regards,
Priyesh.
Back to top
View user's profile Send private message
mvanandkumar

New User


Joined: 01 Sep 2005
Posts: 11

PostPosted: Mon Oct 17, 2005 3:44 pm    Post subject:
Reply with quote

Hi,

Before FRANK the guru replies........here is my 2 cents of addition to Priyesh's answer

//SYSIN DD *
OPTION VLSHRT
SORT FIELDS=(54,10,CH,A),
SKIPREC=1,
STOPAFT=N
/*

Output dataset attributes will be same as Input dataset attributes i.e., RECFM, LRECL etc....

1) OPTION VLSHRT - will tell DFSORT to expect input records LESS THAN Sort fields criteria i.e., 54:10.

2) If you want to convert to FB then use option VTOF i.e., Variable to Fixed

3) VLFILL=C'X' to fill the pad / extra spaces at right side with X characters.

4) To exclude Last record (STOPAFT = N) WILL NOT work. To overcome that problem we need to change SORT crieteria to exclude Detail record...But this is the crude way....

Now....the focus turns to Frank the GURU.....

Thanks
Anand
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Oct 17, 2005 8:51 pm    Post subject:
Reply with quote

Kran,

The DFSORT job below will do what I think you asked for.

Since you didn't supply a lot of details, I'm going to make some assumptions. If these assumptions are wrong, then change the job accordingly, or supply the details if you want me to show you how to change the job.

Assumptions:
1) When you say "We want to sort the detail records based on some reference number with an offset of (50 : 10) in detail record", you're not counting the RDW in positions 1-4, so the sort field actually starts in position 54. And its a 10-byte CH sort field.
2) When you say "we want to skip the both header and trailer records", you really mean that you want to keep the HEADER and TRAILER records as the first and last records respectively and only sort the DETAIL records in between.
3) There's something in the HEADER and TRAILER records that identifies them, e.g. 'HEADER' in positions 5-10 and 'TRAILER' in positions 5-11.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT DD DSN=...  output file (VB)
//SYSIN    DD    *
* Reformat HEADER record to:
* |RDW|'0'|blanks|input|
  INREC IFTHEN=(WHEN=(5,6,CH,EQ,C'HEADER'),
           BUILD=(1,4,5:C'0',6:10X,16:5)),
* Reformat TRAILER record to:
* |RDW|'9'|blanks|input|
        IFTHEN=(WHEN=(5,6,CH,EQ,C'TRAILER'),
           BUILD=(1,4,5:C'9',6:10X,16:5)),
* Reformat DETAIL record to:
* |RDW|'1'|key...|input|
        IFTHEN=(WHEN=NONE,
           BUILD=(1,4,5:C'1',6:54,10,16:5))
* Sort on id/key (id is '0', '1' or '9')
  SORT FIELDS=(5,11,CH,A)
* Reformat records back to:
* |RDW|input|
  OUTREC FIELDS=(1,4,16)
/*
Back to top
View user's profile Send private message
kranti

New User


Joined: 10 Oct 2005
Posts: 27

PostPosted: Mon Oct 17, 2005 9:54 pm    Post subject: Re: DFSORT for a variable length file with few constraints.
Reply with quote

Hi Frank,
We are very thankful to your reply. Following are the comments for your assumptions.

1. You are correct. reference number will start from 54 and of length 10 (54 : 10).

2. we dont want to see the header and trailer records in the output dataset and want to sort only detail records based on reference number as explained in my earlier mail.

3. first three characters (5 : 3) of the record are zeroes indicates header record. first three characters (5 : 3) of the record are 999 indicates trailer record.

Sorry to say that the solution which u have provided will not work for us.Since we are not using the advanced version,IFTHEN will not work in our environment.


Can you please suggest any alternate solution.

Thanks Again,
Kran.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Oct 17, 2005 11:17 pm    Post subject:
Reply with quote

Kran,

If you actually want to remove the header and trailer records, then you don't need IFTHEN. You can use this DFSORT job:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (VB)
//SORTOUT  DD DSN=...  output file (VB)
//SYSIN    DD    *
* Omit the header and trailer records.
   OMIT COND=(5,3,CH,EQ,C'000',OR,5,3,CH,EQ,C'999')
* Sort the detail records.
   SORT FIELDS=(54,10,CH,A)
/*
Back to top
View user's profile Send private message
kranti

New User


Joined: 10 Oct 2005
Posts: 27

PostPosted: Tue Oct 18, 2005 9:50 am    Post subject: Re: DFSORT for a variable length file with few constraints.
Reply with quote

Hi Frank,

Thanks alot.It's working well.Thanks to Priyesh and Anand also for their valuable suggesions.

Thanks For your support,
Kran.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us