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

Syncsort - repeat recs


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajesh1183

New User


Joined: 07 Jan 2008
Posts: 98
Location: Hyderabad

PostPosted: Wed Jul 04, 2012 4:52 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 04, 2012 7:41 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Jul 05, 2012 10:18 am
Reply with quote

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
View user's profile Send private message
rajesh1183

New User


Joined: 07 Jan 2008
Posts: 98
Location: Hyderabad

PostPosted: Thu Jul 05, 2012 5:32 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 7:13 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jul 05, 2012 7:16 pm
Reply with quote

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
View user's profile Send private message
rajesh1183

New User


Joined: 07 Jan 2008
Posts: 98
Location: Hyderabad

PostPosted: Fri Jul 06, 2012 10:04 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 06, 2012 11:46 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jul 06, 2012 3:13 pm
Reply with quote

What 'standard' order?
Back to top
View user's profile Send private message
rajesh1183

New User


Joined: 07 Jan 2008
Posts: 98
Location: Hyderabad

PostPosted: Fri Jul 06, 2012 7:17 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Fri Jul 06, 2012 7:21 pm
Reply with quote

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
View user's profile Send private message
rajesh1183

New User


Joined: 07 Jan 2008
Posts: 98
Location: Hyderabad

PostPosted: Fri Jul 06, 2012 11:59 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Sat Jul 07, 2012 12:12 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jul 07, 2012 12:27 am
Reply with quote

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
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Build a record in output file and rep... DFSORT/ICETOOL 11
No new posts Repeat a DD line- comment and insert ... CA Products 3
No new posts Creating CSV file from Variable recs ... DFSORT/ICETOOL 11
No new posts SORT - To repeat a string in same col... SYNCSORT 3
Search our Forums:

Back to Top