IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DFSORT for a variable length file with few constraints.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1448
Location: Chicago, IL

PostPosted: Mon Oct 17, 2005 2:27 pm
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
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 Developer


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

PostPosted: Mon Oct 17, 2005 8:51 pm
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
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 Developer


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

PostPosted: Mon Oct 17, 2005 11:17 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Store the data for fixed length COBOL Programming 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top