|
View previous topic :: View next topic
|
| Author |
Message |
rajesh1183
New User
Joined: 07 Jan 2008 Posts: 98 Location: Hyderabad
|
|
|
|
Hi All,
Here is my reqmt,
whenever there is 'A' in 10th pos, output rec's 20th position shud be '1'.
whenever there is 'B' in 15th pos, output rec's 20th position shud be '2'.
whenever there is 'A' in 10th pos & 'B' in 15th pos., 2 recs shud be written to output, with 1 rec's 20th position shud be '1' and other record's 20th pos. shud be '2'.
SEQNR's has to be added at the end and shud be restarted whenever there is a change in pos 1-4
RECFM for I/P & O/P files is FB.
Assume LRECL for both files to be 80.
SORT Product : SYNCSORT FOR Z/OS 1.3.0.2R
| Code: |
INPUT:-
----+----1----+----2----+
1234 A
5678 A B
9012 B
|
| Code: |
Expected OUTPUT:-
----+----1----+----2----+----3
1234 1 0001
5678 1 0001
5678 2 0002
9012 2 0001
|
Code Tried:
| Code: |
INREC IFTHEN=(WHEN=(10,1,CH,EQ,C'A'),
BUILD=(1:1,4,20:C'1'),HIT=NEXT),
IFTHEN=(WHEN=(15,1,CH,EQ,C'B'),
BUILD=(1:1,4,20:C'2'))
SORT FIELDS=(1,4,CH,A)
OUTREC FIELDS=(1:1,20,25:SEQNUM,5,ZD,START=1,RESTART=(1,4))
|
Issue:-
How to write a record twice using INREC (Key: 5678 in above example) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
You can't have extra records with INREC, just with OUTFIL. Probably. Check it. I don't have Syncsort documentation.
What you are looking for is the "/", slash operator. |
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try this
| Code: |
//SORT0001 EXEC PGM=SORT
//SORTIN DD *
1234 A
5678 A B
9012 B
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL IFTHEN=(WHEN=(10,1,CH,EQ,C'A',&,
15,1,CH,NE,C'B'),
BUILD=(1,9,20:C'1',80:X)),
IFTHEN=(WHEN=(10,1,CH,NE,C'A',&,
15,1,CH,EQ,C'B'),
BUILD=(1,9,20:C'2',80:X)),
IFTHEN=(WHEN=(10,1,CH,EQ,C'A',&,
15,1,CH,EQ,C'B'),
BUILD=(1,9,20:C'1',80:X,/,1,9,20:C'2',80:X))
/* |
Gerry |
|
| Back to top |
|
 |
rajesh1183
New User
Joined: 07 Jan 2008 Posts: 98 Location: Hyderabad
|
|
|
|
Hi Bill,
Thanks for the tip.
Hi Gerry,
Yeah, I too have written similiar code.
| Code: |
OUTFIL IFTHEN=(WHEN=(10,1,CH,EQ,C'A',&,
15,1,CH,NE,C'B'),
BUILD=(1,9,20:C'1',25:SEQNUM,5,ZD,START=1,RESTART=(1,4),80:X)),
IFTHEN=(WHEN=(10,1,CH,NE,C'A',&,
15,1,CH,EQ,C'B'),
BUILD=(1,9,20:C'2',25:SEQNUM,5,ZD,START=1,RESTART=(1,4),80:X)),
IFTHEN=(WHEN=(10,1,CH,EQ,C'A',&,
15,1,CH,EQ,C'B'),
BUILD=(1,9,20:C'1',25:SEQNUM,5,ZD,START=1,RESTART=(1,4),80:X,
/,
1,9,20:C'2',25:SEQNUM,5,ZD,START=1,RESTART=(1,4),80:X))
SORT FIELDS=COPY
|
Query:
Can the control statements be in any order..?? Does SYNCSORT would arrange them as per it's processing order...? (except the END) |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I'm not exactly sure what you mean.
If you are talking about SORT statements generally, then yes, the SORT product you use is not directly driven by the order in which you write statements.
Try SUM FIELDS=NONE followed by SORT FIELDS=(1,10,CH,A). Etc. The order things will be processed in is documented for DFSORT. Have a look at your documentation for Syncsort.
If it is the IFTHENs you are wondering about, the order of the different types of IFTHEN is important (and documented for DFSORT). Where you have IFTHEN like your exampled, the order processed will not make a difference as they are mutually exclusive.
If not mutually exclusive, only the first test can be true, unless HIT=NEXT is specified (for DFSORT anyway).
If none of the above provides you with an answer or is unclear, ask the question in a better way. |
|
| Back to top |
|
 |
dick scherrer
Moderator Emeritus

Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
| Quote: |
| unless HIT=NEXT is specified (for DFSORT anyway). |
HIT=NEXT has been available in Syncsort since release 1.3.x. |
|
| Back to top |
|
 |
rajesh1183
New User
Joined: 07 Jan 2008 Posts: 98 Location: Hyderabad
|
|
|
|
Hello Bill,
I was talking about SORT control statments only (INREC,OUTREC, OUTFIL, SORT, INCLUDE). Thanks for the answer. So, even the SORT control statements are not as per the standard order (except END), SORT will re-arrange them. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
I don't have the manual, so can't be specific, but the order you write the control cards in is not necessarily the order they will be processed in.
END is optional. I never use it. |
|
| Back to top |
|
 |
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
| What 'standard' order? |
|
| Back to top |
|
 |
rajesh1183
New User
Joined: 07 Jan 2008 Posts: 98 Location: Hyderabad
|
|
|
|
Hi Nic,
"Standard" order - As per the manuals...
-------------
Had an issue with SEQNUM when used the / (Slash operator)
| Code: |
//SORTIN DD *
123AB
/*
//SYSIN DD *
OUTFIL FNAMES=SORTOUT,
IFTHEN=(WHEN=(4,1,CH,EQ,C'A',AND,5,1,CH,EQ,C'B'),
BUILD=(1:1,3,
4:C'A',
10:SEQNUM,3,ZD,RESTART=(1,3),
80:X,
/,
1:1,3,
4:C'B',
10:SEQNUM,3,ZD,RESTART=(1,3),
80:X))
SORT FIELDS=COPY
|
Expected Output:
| Code: |
----+----1----+
123A 001
123B 002
|
Obtained Output:
| Code: |
----+----1----+
123A 001
123B 001
|
I can fix the issue by splitting the above process in 2 steps, but would like to get it done in single step.
Query:
Does the SEQNUM get updated only once in an IFTHEN...?? I couldn't get answer for this from my 600 page SYNCSORT manual... |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
Rajesh,
AFAIK Within a single BUILD, the value of SEQNUM would be the same. Since you are writing only two records, for sure the numbers are known to you - '001' and '002', why don't you hard-code the numbers? |
|
| Back to top |
|
 |
rajesh1183
New User
Joined: 07 Jan 2008 Posts: 98 Location: Hyderabad
|
|
|
|
Arun,
I never know whether my input will have 1 or 100 similiar keys. So, I can't hard code the Seq Nums. The thing which I have given is an example of the issue I was facing... |
|
| Back to top |
|
 |
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2482 Location: @my desk
|
|
|
|
| Quote: |
| I never know whether my input will have 1 or 100 similiar keys. So, I can't hard code the Seq Num |
Rajesh,
If that is the case, even if 100 similar keys are there, your OUTFIL will generate only 2 records since you have only one '/' in it. I wonder how you are gonna attach those 100 sequence numbers to just 2 records.!!
It would be better if you explain your requirement clearly before we proceed any further |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Rajesh,
If you don't understand the manual, why don't you do some very simple tests with DD */SYSOUT=*, including with /.
Then go back and see the manual again, see if you can then uderstand the manual. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|