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

Syncsort to output file in sorted order


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

Moderator Emeritus


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

PostPosted: Thu Apr 05, 2012 3:07 pm
Reply with quote

Are you asking about how to continue a literal to the next line? I'm sure it'll be very clear in your manual.
Back to top
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Thu Apr 05, 2012 3:36 pm
Reply with quote

Thank you. Its working fine.
Back to top
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Thu Apr 05, 2012 6:43 pm
Reply with quote

Hi Bodatrinadh

Thank you for your sort card.
but now I may face some issue like in some case trailer got changed.

for ex if there is no record then the trailer should be 'No record'

so can we we have some thing like in sort where we just copy whatever be the headers and trailers .
for ex: header 3 line and trailer 1 line needs to copied to output file and skipped from sorting.
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 Apr 05, 2012 8:52 pm
Reply with quote

You can try this as a start. Works with DFSORT.

It adds a new field as the first in the SORT. For the first three records, it will contain 1,2,3. The contents of the header are irrelevant for the process, it is just the first three records. For all others except the trailer it will contain 99998. For the trailer, identified as "TOTAL NO' in bytes 1 to 8, it contains 99999.

NB, without EQUALS the order of duplicates in the third field is however the SORT wants to write them. If you want them in some other order if equal, you'll need to do something.

Code:
//S1    EXEC  PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT  DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTIN DD *
PGMNAME
DATE
  HEADER1            HEADER2        HEADER3
 12345678             554579        TOTAL AMOUNT SOLD
 12365789             559870        ALREADY SOLDOUT
 12365786             559873        MIDDLE RECORD
 12365784             559873        CLOSED RECORD
 12365785             559873        EXISTING RECORD
 12365780             559873        MIDDLE RECORD
TOTAL NO OF RECORDS:006
//SYSIN DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(133:SEQNUM,5,ZD)),
        IFTHEN=(WHEN=(133,5,ZD,GT,+3),OVERLAY=(133:C'99998'),
                HIT=NEXT),
        IFTHEN=(WHEN=(1,8,CH,EQ,C'TOTAL NO'),
                OVERLAY=(133:C'99999'))
  SORT FIELDS=(133,5,CH,A,37,25,CH,A)
  OUTREC BUILD=(1,132)


Output is:
Code:

PGMNAME                                             
DATE                                                 
  HEADER1            HEADER2        HEADER3         
 12365789             559870        ALREADY SOLDOUT 
 12365784             559873        CLOSED RECORD   
 12365785             559873        EXISTING RECORD 
 12365786             559873        MIDDLE RECORD   
 12365780             559873        MIDDLE RECORD   
 12345678             554579        TOTAL AMOUNT SOLD
TOTAL NO OF RECORDS:006                             
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Fri Apr 06, 2012 6:07 pm
Reply with quote

Quote:


but now I may face some issue like in some case trailer got changed.

for ex if there is no record then the trailer should be 'No record'


for your request, you can add below OUTREC ( after SORT ) to Bill's code.

Code:

OUTREC IFTHEN=(WHEN=(1,10,SS,EQ,C'TOTAL NO',AND,22,3,ZD,EQ,+0),
       OVERLAY=(22:C' NO RECORDS'))                           


OR

You can use above OUTREC by adding one more sort step to my code.


Thanks
-3nadh
Back to top
View user's profile Send private message
janmejay
Warnings : 1

New User


Joined: 22 Jun 2007
Posts: 85
Location: bangalore

PostPosted: Fri Apr 06, 2012 8:34 pm
Reply with quote

Hi Bill

The code is working fine.

but in sort card SORT FIELDS=(133,5,CH,A,37,25,CH,A)

the TRailer record is coming after all headers.

My output is coming

Code:
PGMNAME                                             
DATE                                                 
TOTAL NO OF RECORDS:006 
HEADER1            HEADER2        HEADER3         
 12365789             559870        ALREADY SOLDOUT 
 12365784             559873        CLOSED RECORD   
 12365785             559873        EXISTING RECORD 
 12365786             559873        MIDDLE RECORD   
 12365780             559873        MIDDLE RECORD   
 12345678             554579        TOTAL AMOUNT SOLD


how to bring trailer to last position..
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Fri Apr 06, 2012 10:06 pm
Reply with quote

Change trailer records condition to
IFTHEN=(WHEN=(1,10,SS,EQ,C'TOTAL NO'),
OVERLAY=(133:C'99999'))


Thanks
-3nadh
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 Apr 06, 2012 11:23 pm
Reply with quote

Well, I did this.

I "quoted" your latest post.

I "coded" your output data.

This I had to do because even after this long topic you haven't caught on to how to Code your own data.

I copied your formatted data. Pasted it as SYSIN. Ran my job. Again received the correct output, trailer at the end.

Without you showing the actual JCL, cards and input data and messages from the step, all Coded, I can only suggest you try to investigate it yourself. Either you have bloopered something, or there is a foible in Syncsort with simple control cards like this.

Now, just to give you a hand with the investigation (so this topic can get near to a termination), try running this:

Code:
//S1    EXEC  PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT  DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTIN DD *
PGMNAME
DATE
  HEADER1            HEADER2        HEADER3
 12365789             559870        ALREADY SOLDOUT
 12365784             559873        CLOSED RECORD
 12365785             559873        EXISTING RECORD
 12365786             559873        MIDDLE RECORD
 12365780             559873        MIDDLE RECORD
 12345678             554579        TOTAL AMOUNT SOLD
TOTAL NO OF RECORDS:006
//SYSIN DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(133:SEQNUM,5,ZD)),
        IFTHEN=(WHEN=(133,5,ZD,GT,+3),OVERLAY=(133:C'99998'),
                HIT=NEXT),
        IFTHEN=(WHEN=(1,8,CH,EQ,C'TOTAL NO'),
                OVERLAY=(133:C'99999'))
  SORT FIELDS=(133,5,CH,A,37,25,CH,A)
  OUTREC BUILD=(1,60,133,5)


All I've done is changed the OUTREC so that some trailing blanks are not shown, but the sequence number which has been appended is.

Gives this output, with the latest data you have shown:

Code:
PGMNAME                                                     00001
DATE                                                        00002
  HEADER1            HEADER2        HEADER3                 00003
 12365789             559870        ALREADY SOLDOUT         99998
 12365784             559873        CLOSED RECORD           99998
 12365785             559873        EXISTING RECORD         99998
 12365786             559873        MIDDLE RECORD           99998
 12365780             559873        MIDDLE RECORD           99998
 12345678             554579        TOTAL AMOUNT SOLD       99998
TOTAL NO OF RECORDS:006                                     99999


EDIT: If "TOTAL NO" is not actually in 1,8, try -3nadh's suggestion or use the position where it actually is, if fixed.

To your "sometimes there are no records", what does that look like on the input data? If it does not start "TOTAL NO" then code another IFTHEN in the same style taking the same action as the first for the trailer.
Back to top
View user's profile Send private message
bodatrinadh

Active User


Joined: 05 Jan 2007
Posts: 101
Location: chennai (India)

PostPosted: Sat Apr 07, 2012 12:44 am
Reply with quote

Apologies, I am the culprit who moved the trailer record one step right unintentionally. Since then TS is referring the input from my first post and ignored the actual input.

Thanks
-3nadh
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 Apr 07, 2012 2:44 am
Reply with quote

Fine words, -3nadh, but I'd not blame you. I used TS's latest data...

Anyway, the request was to leave the first three and the last record undisturbed, and it looks like the last record might have multiple values (possibly different locations), so...

Code:
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(133:SEQNUM,5,ZD)),
        IFTHEN=(WHEN=(133,5,ZD,GT,+3),OVERLAY=(133:C'99998'),
               HIT=NEXT),             
        IFTHEN=(WHEN=(133,5,ZD,GT,+3,AND,2,1,FS,NE,NUM),
                OVERLAY=(133:C'99999'))
  SORT FIELDS=(133,5,CH,A,37,25,CH,A)
  OUTREC BUILD=(1,60,133,5)


This is entirely untested. I "borrowed" the NUM from -3nadh's first solution, but have restricted it to testing one byte. Check that that is long enough for your known data. Now, assuming it works, the last record, assuming it does not have a numeric in position 2, will be outsorted from the data records whatever the actual content of the last/trailer record.

I have left the OUTREC as the "testing" version.

I have to keep remembering how simple this was with DATASORT :-)
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 Apr 07, 2012 3:32 am
Reply with quote

Code:
PGMNAME
DATE
  HEADER1            HEADER2        HEADER3
 12365784             559873        CLOSED RECORD
 12365780             559873        MIDDLE RECORD
 12365785             559873        EXISTING RECORD
 12345678             554579        TOTAL AMOUNT SOLD
 12365786             559873        MIDDLE RECORD
 12365789             559870        ALREADY SOLDOUT
A PILE OF PIES


Gives:
Code:
PGMNAME                                                     00001
DATE                                                        00002
  HEADER1            HEADER2        HEADER3                 00003
 12365789             559870        ALREADY SOLDOUT         99998
 12365784             559873        CLOSED RECORD           99998
 12365785             559873        EXISTING RECORD         99998
 12365786             559873        MIDDLE RECORD           99998
 12365780             559873        MIDDLE RECORD           99998
 12345678             554579        TOTAL AMOUNT SOLD       99998
A PILE OF PIES                                              99999
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10888
Location: italy

PostPosted: Fri Apr 13, 2012 7:22 pm
Reply with quote

35 posts, looks more like a soap opera than an IT topic.

anyway topic locked,
people are starting to post here instead of starting a new topic with their questions
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 Goto page Previous  1, 2

 


Similar Topics
Topic Forum Replies
No new posts Unable to interpret a hex value to De... COBOL Programming 7
No new posts Syncsort help SYNCSORT 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts SYNCSORT-DB2 interface SYNCSORT 0
No new posts Reroute print output via REXX/SDSF TSO/ISPF 6
Search our Forums:

Back to Top