Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 1529
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: 7232

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: 7232

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: 7232

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: 10202
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: 7232

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: 7232

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 High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us