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

Sort all record except the first, but write also excluded


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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

Global Moderator


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

PostPosted: Thu Jun 07, 2012 7:55 pm
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
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
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

Global Moderator


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

PostPosted: Thu Jun 07, 2012 8:11 pm
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
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
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

Global Moderator


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

PostPosted: Thu Jun 07, 2012 8:50 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top