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 all record except the first, but write also excluded

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
michele_mimi

New User


Joined: 22 Feb 2008
Posts: 7
Location: Rome, Italy

PostPosted: Thu Jun 07, 2012 7:01 pm    Post subject: Sort all record except the first, but write also excluded
Reply with quote

Hi,
I have this input file

Code:

CIT;EN;
ABJ;UV;
ACC;UZ;
ACC;UV;
ACD;UV;
ADD;UV;
ACC;UP;


My request is:
a output file with sort (length 7 byte) of all record except the first record but that be written in the first row
This is output file :

Code:

CIT;EN;
ABJ;UV;
ACC;UP;
ACC;UV;
ACC;UZ;
ACD;UV;
ADD;UV;


Sorry for my anglish and thank you !!!
Back to top
View user's profile Send private message

Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Thu Jun 07, 2012 7:25 pm    Post subject:
Reply with quote

You can try this.

Code:
//STEP0100 EXEC  PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//SORTOUT  DD SYSOUT=*
//SORTIN   DD *
CIT;EN;
ABJ;UV;
ACC;UZ;
ACC;UV;
ACD;UV;
ADD;UV;
ACC;UP;
//SYSIN DD *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,2,ZD)),
        IFTHEN=(WHEN=(81,2,ZD,GT,+1),OVERLAY=(81:C'99'),
                HIT=NEXT)
  SORT FIELDS=(81,2,CH,A,1,7,CH,A)
  OUTREC BUILD=(1,7)
/*
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 07, 2012 7:49 pm    Post subject:
Reply with quote

don't think you need the hit=next,

also, why not
Code:
INIT BUILD=(1:C'1',2:1,7),
ANY  BUILD=(1:C'2',2:1,7)

sort 1,8

BUILD=(2,8)
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Thu Jun 07, 2012 7:55 pm    Post subject:
Reply with quote

HI here is an Icetool step using DATASORT

Code:
//STEP0100  EXEC  PGM=ICETOOL
//TOOLMSG   DD SYSOUT=*
//DFSMSG    DD SYSOUT=*
//IN        DD *
CIT;EN;
ABJ;UV;
ACC;UP;
ACC;UV;
ACC;UZ;
ACD;UV;
ADD;UV;
//OUT      DD  SYSOUT=*
//TOOLIN    DD *
  DATASORT FROM(IN) TO(OUT) HEADER USING(CTL1)
//CTL1CNTL  DD *
  SORT FIELDS=(1,3,CH,A,5,2,CH,A)
Back to top
View user's profile Send private message
michele_mimi

New User


Joined: 22 Feb 2008
Posts: 7
Location: Rome, Italy

PostPosted: Thu Jun 07, 2012 8:05 pm    Post subject:
Reply with quote

Naish wrote:

...
...

You can try this.


Ok !!! Perfect, tks icon_smile.gif
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jun 07, 2012 8:05 pm    Post subject:
Reply with quote

Pandora-Box,

even simpler. very good.

i had not thought of HEADER option on the DATASORT to skip the first,
but why did you break up the sort key into 2 parts?
why not just 1,7 ?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Thu Jun 07, 2012 8:11 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
even simpler. very good.


Thanks

dbzTHEdinosauer wrote:
i had not thought of HEADER option on the DATASORT to skip the first,
but why did you break up the sort key into 2 parts?
why not just 1,7

I am just realising the sort commands which I could use for the update release in myshop.So utilising it to the max icon_smile.gif

Agreed It can be clubbed to one as 1,7,CH,A
Back to top
View user's profile Send private message
michele_mimi

New User


Joined: 22 Feb 2008
Posts: 7
Location: Rome, Italy

PostPosted: Thu Jun 07, 2012 8:31 pm    Post subject:
Reply with quote

dbzTHEdinosauer wrote:
don't think you need the hit=next,

It's true, HIT=NEXT not necessary....

dbzTHEdinosauer wrote:

also, why not
Code:
INIT BUILD=(1:C'1',2:1,7),
ANY  BUILD=(1:C'2',2:1,7)

sort 1,8

BUILD=(2,8)




I try this:

Code:

//SYSIN DD *                                   
 INREC IFTHEN=(WHEN=INIT,BUILD=(1:C'1',2:1,7)),
       IFTHEN=(WHEN=ANY,BUILD=(1:C'2',2:1,7)) 
 SORT FIELDS=(1,8,CH,A)                       
 OUTREC BUILD=(2,8)                           
/*                                             

but take this error :
Code:

ICE000I 1 - CONTROL STATEMENTS FOR 5694-A01, Z/OS DFSORT V1R10 - 16:56 ON THU JU
           INREC IFTHEN=(WHEN=INIT,BUILD=(1:C'1',2:1,7),HIT=NEXT),             
                 IFTHEN=(WHEN=ANY,BUILD=(1:C'2',2:1,7))                         
                              $                                                 
ICE107A F DUPLICATE, CONFLICTING, OR MISSING INREC OR OUTREC STATEMENT OPERANDS
           SORT FIELDS=(1,8,CH,A)                                               
           OUTREC BUILD=(2,8)                                                   
ICE751I 0 C5-K90025 C6-K90025 C7-K54603 C8-K62201 E7-K62201                     
ICE052I 3 END OF DFSORT                                                         
Back to top
View user's profile Send private message
michele_mimi

New User


Joined: 22 Feb 2008
Posts: 7
Location: Rome, Italy

PostPosted: Thu Jun 07, 2012 8:35 pm    Post subject:
Reply with quote

Pandora-Box wrote:
HI here is an Icetool step using DATASORT



Also this it's OK icon_smile.gif

Thank you ...
Back to top
View user's profile Send private message
Pandora-Box

Moderator


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

PostPosted: Thu Jun 07, 2012 8:50 pm    Post subject:
Reply with quote

Quote:
but take this error :


The Error is because you can use WHEN=ANY only after single or multiple logical expressions

Where as here WHEN=INIT is not same as WHEN=(logexp)

Quote:
WHEN=ANY: Use a WHEN=ANY clause after multiple WHEN=(logexp) clauses to apply additional build or overlay items to your input records if they satisfied the criteria for any of the preceding WHEN=(logexp) clauses.
Back to top
View user's profile Send private message
michele_mimi

New User


Joined: 22 Feb 2008
Posts: 7
Location: Rome, Italy

PostPosted: Thu Jun 07, 2012 9:25 pm    Post subject:
Reply with quote

Naish wrote:
I tried using WHEN=(logexp) and WHEN=ANY but couldn't get correct o/p.
...
...


All true...

In fact I try this:
Code:

//SYSIN DD *                                                 
 INREC IFTHEN=(WHEN=INIT,BUILD=(1:C'1',2:1,7)),             
       IFTHEN=(WHEN=(1,3,CH,EQ,C'123'),BUILD=(1:C'2',2:1,7)),
       IFTHEN=(WHEN=ANY,BUILD=(1:C'2',2:1,7))               
 SORT FIELDS=(1,8,CH,A)                                     
 OUTREC BUILD=(2,8)                                         
/*                                                           


but fail more




Naish wrote:

The proposed solution might fail when the first record contains any record apart from CIT.



With NONE parameter it's ok for me because I post the simple example, but really my input file is done in this way :
Code:

CITTAENTECOM;ENTECOM;MERGEO;CANVEN;VALPAN;CDC;CDCAP;CANVENITA;VAUTABUDGET;VALCONT;OLDENTE;CITOLDENT;IMPUTAZ;PAE
BOD;UP;TBOM;Ato/Cto;USD;71011;71011;;EUR;;APC;BOM;;NN         
BOM;UP;TBOM;Indiretto;USD;71000;71000;;EUR;;APC;BOM;;NN       
WIN;UP;TBOM;Web;USD;77020;77020;;EUR;;APC;BOM;;NN             
OFD;UP;TOFF;Ato/Cto;USD;77011;77011;;EUR;;APC;OFF;;NN 
OFF;UP;TOFF;Indiretto;USD;77001;77001;;EUR;;APC;OFF;;NN
WOF;UP;TOFF;Web;USD;75021;75021;;EUR;;APC;OFF;;NN     
SHD;UP;TSHA;Ato/Cto;USD;78111;78111;;EUR;;APC;PEK;;NN         
SHA;UP;TSHA;Indiretto;USD;78100;78100;;EUR;;APC;PEK;;NN       
WCN;UP;TSHA;Web;USD;78021;78021;;EUR;;APC;PEK;;NN             
SED;UP;TSEL;Ato/Cto;USD;78010;78010;;EUR;;APC;SEL;;NN         
...
...
...

and so on...

and then I can exclude easily the first row without afraid to take more records
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Jun 07, 2012 9:42 pm    Post subject: Reply to: Sort all record except the first, but write also e
Reply with quote

ICETOOL's Datasort is the Best way to get the desired results.

WHEN=INIT and WHEN=GROUP gets executed First followed by WHEN=(logexp). You would only need HIT=NEXT when you are using WHEN=(logexp).

And Based on the sample input shown by OP , I am guessing that it is a variable length file and IFTHEN solution is adding characters at end will ruin the concept of Variable block files.

With Datasort you do NOT have to worry about format and lrecl of the file as long as you get the correct fields to SORT considering the RDW.
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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 How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


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