Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Sort based on condition and write into 2 files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Tue Feb 05, 2013 11:43 am    Post subject: Sort based on condition and write into 2 files
Reply with quote

Hi,

I have a requirement to sort the input with LRECL = 2882 Format = FB.
I have to sort the field (72,2,BI,A) and then i have to copy only the last record in one file and the rest of all the records in another file. Can someone advise on how to proceed.

I can use SUBSET if i need to extract only the last record. But i need rest of the records in another file.

Thanks,
thala_ds.
Back to top
View user's profile Send private message

Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1542
Location: Andromeda Galaxy

PostPosted: Tue Feb 05, 2013 11:57 am    Post subject:
Reply with quote

Do we have an identifier to find the last record after sort?
Back to top
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Tue Feb 05, 2013 12:01 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Hi,

After sorting, that field will have the maximum value(in position we sorted -->72,2). I have to extract only that maximum value record in one file and rest of the record in another file. We don't have any other identifier.

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Feb 05, 2013 12:24 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

I suggest you get back to the manual, read up on SUBSET, experiment, then implement it. Pay attention to USING.

Please don't give answers like this to perfectly reasonable questions:

Quote:
After sorting, that field will have the maximum value(in position we sorted -->72,2)
Back to top
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Tue Feb 05, 2013 12:44 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Bill,

Thanks.. I was able to get the required output using the below ICETOOL as you suggested.

SUBSET FROM(IN1) TO(OUT1) DISCARD(OUT2) KEEP INPUT LAST(1)

Thanks a lot.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Feb 05, 2013 1:15 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Well done, but I don't see a SORT anywhere. You're not SORTing first then using SUBSET are you?

Code:

what you have plus USING(xxxx)

xxxxCNTL

  SORT FIELDS=(72,2,BI,A)


Then you only have one pass of the file. Pay attention to the documentation if you feel it doesn't "work".
Back to top
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Tue Feb 05, 2013 1:19 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Bill,

Yes. i have to sort before using subset. Please see my sort card below.
//TOOLIN DD *
SUBSET FROM(IN1) TO(OUT1) DISCARD(OUT2) KEEP INPUT LAST(1) -
USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(72,2,BI,A)
/*

The above statement is failing with RC=16. But if i use SORT FIELDS=COPY, its running fine. Can you please help me on that?.

Thanks.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Feb 05, 2013 1:22 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Can you show the sysout of the failure please?
Back to top
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Tue Feb 05, 2013 1:25 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Bill,

Here is the SYSOUT of the failing job.

Code:

SYNCSORT FOR Z/OS  1.3.2.1RI   U.S. PATENTS: 4210961, 5117495   (C) 2007 SYNCSO
                                                      z/OS   1.12.0
SYNCSORT LICENSED FOR CPU SERIAL NUMBER 40BE0, MODEL 2817 752             LICEN
CTL1CNTL :
  SORT FIELDS=(72,2,BI,A)
PARMLIST :
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=IN1,SORTDD=CTL1,SORTOUT=OUT1,DYNA
LLOC,CMP=CLC,NOVLSHRT,EQUALS
SORT FIELDS=COPY
MODS E15=(SYNC##15,4096,,N)
OUTFIL FNAMES=OUT1
OUTFIL FNAMES=OUT2
WER428I  CALLER-PROVIDED IDENTIFIER IS "0001"
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE


Code'd
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10354
Location: italy

PostPosted: Tue Feb 05, 2013 1:30 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

You posted on the DFSORT section of the Forum
and people wasted time trying to diagnose a problem for the wrong environment

topic moved where it belongs
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Feb 05, 2013 3:44 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Is that all the sysout?

You have a fairly old SyncSort. Maybe do the two-step for now, and I'll try to dig up a different solution when I have more time.
Back to top
View user's profile Send private message
thala_ds

New User


Joined: 05 Jun 2012
Posts: 18
Location: India

PostPosted: Tue Feb 05, 2013 3:47 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Bill,

I slightly modified the same sort card and got the expected output.

Code:
//TOOLIN   DD *
  SUBSET FROM(IN1) TO(OUT1) DISCARD(OUT2) KEEP [color=red]OUTPUT[/color] LAST(1) -
    USING(CTL1)
/*
//CTL1CNTL DD *
  SORT FIELDS=(72,2,BI,A)
/*

Thanks for your help on this.

Code'd again
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7314

PostPosted: Tue Feb 05, 2013 4:05 pm    Post subject: Reply to: Sort based on condition and write into 2 files
Reply with quote

Please use the Code tags to preserve spacing.

With DFSORT I got an error message for INPUT. Without an error message from SyncSort I thought maybe not worth telling you to change to OUTPUT. INPUT is the wrong place anyway, as it would be the last record of the unsorted file.

Thanks for letting us know.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Split files upto certain limit based ... bubbu75 DFSORT/ICETOOL 5 Tue Nov 14, 2017 11:11 pm
No new posts JOINKEYS Paired and Unpaired Sort on ... MFwhiz DFSORT/ICETOOL 7 Tue Nov 07, 2017 2:46 am
No new posts Copy selected columns from 2 input fi... Poha Eater DFSORT/ICETOOL 3 Thu Nov 02, 2017 3:43 pm
No new posts Finding difference between two PS fil... Vignesh Sid SYNCSORT 5 Mon Oct 30, 2017 1:13 pm
No new posts NDM 300 files from mainframe to linux shreya19 All Other Mainframe Topics 2 Thu Oct 26, 2017 11:40 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us