View previous topic :: View next topic
|
Author |
Message |
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Hi All,
I am having following requirement
Input Dataset Type VB
At 7 column At 55th Column
JAB 12345
JBC 23456
BCA 34567
Change before sort that needs to be done is
JAB 01
JBC 02
BCA 03
Now I need to sort them based on changed field and data at column 55 and report it into dataset of LRECL 80 ,RECFM is FB.
The o/p of the above sample data will be:
01 12345
02 23456
03 34567
Can we achive this using sort. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Your description is not very clear. For example, the data at position 7 doesn't seem to matter. But assuming that position 55 includes the RDW, and you want to sort by the added 2 digit sequence number and the 5 byte field starting at position 5, here's a DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (FB/80)
//SYSIN DD *
INREC BUILD=(1,4,SEQNUM,2,ZD,X,55,5)
SORT FIELDS=(5,2,CH,A,8,5,CH,A)
OUTFIL VTOF,BUILD=(5,8,80:X)
/*
|
If that's not what you want, then please describe more clearly what you do want. |
|
Back to top |
|
|
rgupta71
Active User
Joined: 21 Jun 2009 Posts: 160 Location: Indore
|
|
|
|
Here is a better example
JAB 12345
JBC 23456
BCA 34567
JAB 56789
JBC 67890
BCA 78901
Output data
01 12345
01 56789
02 23456
02 67890
03 34567
03 78901
I was able to do using 2 sort step.1st step to change the JAB to 01.JBC to 02 and BCA to 03.In 2nd step sorted in ascending order as 1st 2 column as primary column.Can we do it using one sort step?Is it a good practice to use INREC and OUTREC together?
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Is there some reason you did not post both input files for the "better" example?
Is there some reason you did not post your solution?
The more completely you post, the more likely you are to receive usable replies quickly. . . |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
In one step (pass), you can do the change with INREC, then the SORT and the OUTFIL to convert to FB. You can use INREC with IFTHEN clauses or INREC with CHANGE to do the change.
However, it's still not clear what you're trying to do. Are you only interested in the values 'JAB', 'JBC' and 'BCA' or can there be more/different values? If so, how would they be handled?
Are you trying to sort in the order:
JAB,number
JBC,number
BCA,number
or in some other way?
Since you don't have JAB, etc in the output, why do you need to change to JAB.01 instead of just to 01? |
|
Back to top |
|
|
|