View previous topic :: View next topic
|
Author |
Message |
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Hi All,
I have one input file length of 80 bytes.
There is one field at position 71 (lenth of 7 bytes). Lets say user-id.
I need to fetch only user-id from that file and also that field needs to be sorted on ascending order and duplicates needs to be removed.
So the output file should contain only user-id field which is sorted with no-dups.
Can any one help me on this???
thanks in advance. |
|
Back to top |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
You need a card to sort:
Code: |
SORT FIELDS=(71,7,CH,A)
|
You need a card to select the only records with userids ( NE TO BLANK)
Code: |
INCLUDE COND=(71,7,CH,NE,C' ')
|
You need a card to remove dups:
If you want to have the userid moved to to position 1:
Code: |
OUTREC FIELDS=(1:71,7,8:73C' ')
|
|
|
Back to top |
|
|
Succor
New User
Joined: 20 Feb 2009 Posts: 96 Location: Bangalore :)
|
|
|
|
Raj12vel,You can try this ,altering the data type if required.
Code: |
//JS010 EXEC PGM=SORT
//SORTIN DD DSN=INP.FIL1,
// DISP=SHR
//SORTOUT DD DSN=OUT.FIL2,
// DISP=SHR
//SORTMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(71,7,CH,A)
SUM FIELDS=NONE
OUTREC FIELDS=(1:71,7)
/*
// |
WTH. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
It might be more efficient to select ONLY the required field BEFORE sorting using INREC rather than removing the unwanted fields after sorting using an OUTREC. Just a thought.
Code: |
//SYSIN DD *
INREC BUILD=(71,7)
SORT FIELDS=(1,7,CH,A)
SUM FIELDS=NONE
/* |
|
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Hi all,
Thanks for all your response!!!
the below statement meets my last requirement.
OUTREC FIELDS=(1:71,7,8:73C' ')
but getting an error
INREC RECORD LENGTH = 7
OUTREC FIELD OUTSIDE RANGE
please help me on this.
All other code works fine but getting buffer values at the remaining position of the output file. thats why going for this command to make the remaining field as spaces. |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Quote: |
but getting an error
INREC RECORD LENGTH = 7
OUTREC FIELD OUTSIDE RANGE
please help me on this.
|
Please provide all your sysouts...... |
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Hi All,
I tried with these cards,
Code: |
//SYSIN DD *
SORT FIELDS=(71,7,CH,A)
INCLUDE COND=(71,7,CH,NE,C' ')
OUTREC FIELDS=(1:71,7,8:73C' ')
/* |
It works fine. but when i insert sumfields=none, getting an error. here it's go.
Code: |
SORT FIELDS=(71,7,CH,A)
INCLUDE COND=(71,7,CH,NE,C' ')
OUTREC FIELDS=(1:71,7,8:73C' ')
SUMFIELDS=NONE |
Error:-
SYSIN :
Code: |
SORT FIELDS=(71,7,CH,A)
INCLUDE COND=(71,7,CH,NE,C' ')
OUTREC FIELDS=(1:71,7,8:73C' ')
SUMFIELDS=NONE
*
WER901I **WARNING** SYNCSORT 1.2.3.0 WILL EXPIRE IN 34 DAYS
WER275A NO KEYWORDS FOUND ON CONTROL STATEMENT
WER449I SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE |
|
|
Back to top |
|
|
cpuhawg
Active User
Joined: 14 Jun 2006 Posts: 331 Location: Jacksonville, FL
|
|
|
|
There needs to be a space between SUM and FIELDS=NONE |
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Great!!!
Thanks alot your timed help!!!
|
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Thank you all!!!
All the cards work fine now... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Is there some reason you chose to sort all of the data instead of only the 7 bytes you wanted as output?
If you have 50 records it will not matter, if you have 50 millon records, it will. . . |
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Need to have it. Thats why. Any ways thanks alot.
Got another situation here.
I have two input files.
1. Length of 80 bytes (user-id at position 71, length of 7 bytes)
2. length of 80 bytes (user-id at position 01,length of 7 bytes)
requirement:-
1. User id needs to be matched with both files,
2. if matches, then all the records from 1st file (80 bytes) and the field from position 09 to 10 (i.e 2 bytes) will be written into the output.
can any one help me on this? |
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Input:-
I have two input files.
1. Length of 80 bytes (user-id at position 71, length of 7 bytes)
2. length of 80 bytes (user-id at position 01,length of 7 bytes)
requirement:-
1. User id needs to be matched with both files,
2. if matches, then all the records from 1st file (80 bytes) and the field from position 09 to 10 (i.e 2 bytes) will be written into the output.
can any one help me on this?
_________________
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you look at join/joinkeys in the Syncsort manual.
There are also multiple examples in the forum (SEARCH link is above).
If you find something that is not clear, p[ost what you found and someone will be able to clarify. |
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
Hi,
Got the code for the above question..
Thanks alot.
But if there is no match between the user-id's then need to populate
the value as "???" in the output file?
here what condition we have to include...
here is the code i have used now:-
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(71,07,A)
JOINKEYS FILE=F2,FIELDS=(01,07,A)
REFORMAT FIELDS=(F1:1,80,F2:9,2)
SORT FIELDS=(71,7,CH,A)
OUTREC FIELDS=(1,80,81,02,83:8C' ')
/*
please help me on this... |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Have you looked at the idea of mulitpule OUTRECs pointing to the same output? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
But if there is no match between the user-id's then need to populate
the value as "???" in the output file? |
raj12vel,
Here mismatch can come both the ways.
1) Key from File1 not present in File2
2) Key from File2 not present in File1
Define your output records for both the above cases. |
|
Back to top |
|
|
raj12vel
New User
Joined: 20 Dec 2008 Posts: 43 Location: New Jersey
|
|
|
|
1. Input File1
Code: |
USER-ID
131143305 3899 15.00 20090504 IVR JCPPLCCPBP G1VPRLT N
131143317 9626 113.00 20090504 IVR gapplccpbp IVR N
131143332 8117 16.00 20090503 IVR GAPPLCCPBP IVR N
131143383 9039 516.93 20090503 IVR JCPDCPBP G1VPD1T N
|
2. Input file2
Code: |
USER-ID
G1VPRLT cs
G1VPD1T cs
|
Output file required;-
Code: |
USER-ID new field
from input 2
131143305 3899 15.00 20090504 IVR JCPPLCCPBP G1VPRLT N cs
131143317 9626 113.00 20090504 IVR gapplccpbp IVR N ???
131143332 8117 16.00 20090503 IVR GAPPLCCPBP IVR N ???
131143383 9039 516.93 20090503 IVR JCPDCPBP G1VPD1T N cs
|
Hope this will be useful... |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
raj12vel,
Your field positions in the sample data(key at pos-50) does n't seem to match with what you've used in your sort cards(pos-71). The below JOIN UNPAIRED application should work for you. You can modify the field positions as in your actual file.
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTJNF1 DD *
131143305 3899 15.00 20090504 IVR JCPPLCCPBP G1VPRLT N
131143317 9626 113.00 20090504 IVR GAPPLCCPBP IVR N
131143332 8117 16.00 20090503 IVR GAPPLCCPBP IVR N
131143383 9039 516.93 20090503 IVR JCPDCPBP G1VPD1T N
/*
//SORTJNF2 DD *
G1VPRLT cs
G1VPD1T cs
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(50,7,A)
JOINKEYS FILE=F2,FIELDS=(01,7,A)
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,58,F2:8,4)
INREC IFTHEN=(WHEN=(61,1,CH,EQ,C' '),OVERLAY=(60:C'???'))
SORT FIELDS=(1,9,CH,A) |
SORTOUT
Code: |
131143305 3899 15.00 20090504 IVR JCPPLCCPBP G1VPRLT N cs
131143317 9626 113.00 20090504 IVR GAPPLCCPBP IVR N ???
131143332 8117 16.00 20090503 IVR GAPPLCCPBP IVR N ???
131143383 9039 516.93 20090503 IVR JCPDCPBP G1VPD1T N cs |
|
|
Back to top |
|
|
|