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

Sort based on condition and write into 2 files


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Tue Feb 05, 2013 11:57 am
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
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

Moderator Emeritus


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

PostPosted: Tue Feb 05, 2013 12:24 pm
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
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

Moderator Emeritus


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

PostPosted: Tue Feb 05, 2013 1:15 pm
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
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

Moderator Emeritus


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

PostPosted: Tue Feb 05, 2013 1:22 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Tue Feb 05, 2013 1:30 pm
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

Moderator Emeritus


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

PostPosted: Tue Feb 05, 2013 3:44 pm
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
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

Moderator Emeritus


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

PostPosted: Tue Feb 05, 2013 4:05 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top