|
View previous topic :: View next topic
|
| Author |
Message |
michele_mimi
New User
Joined: 22 Feb 2008 Posts: 7 Location: Rome, Italy
|
|
|
|
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 |
|
 |
Naish
New User

Joined: 07 Dec 2006 Posts: 82 Location: UK
|
|
|
|
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 |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
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 |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
 |
michele_mimi
New User
Joined: 22 Feb 2008 Posts: 7 Location: Rome, Italy
|
|
|
|
| Naish wrote: |
...
...
You can try this.
|
Ok !!! Perfect, tks  |
|
| Back to top |
|
 |
dbzTHEdinosauer
Global Moderator

Joined: 20 Oct 2006 Posts: 6965 Location: porcelain throne
|
|
|
|
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 |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| 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
Agreed It can be clubbed to one as 1,7,CH,A |
|
| Back to top |
|
 |
michele_mimi
New User
Joined: 22 Feb 2008 Posts: 7 Location: Rome, Italy
|
|
|
|
| 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 |
|
 |
michele_mimi
New User
Joined: 22 Feb 2008 Posts: 7 Location: Rome, Italy
|
|
|
|
| Pandora-Box wrote: |
HI here is an Icetool step using DATASORT
|
Also this it's OK
Thank you ... |
|
| Back to top |
|
 |
Pandora-Box
Global Moderator
.jpg)
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
| 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 |
|
 |
michele_mimi
New User
Joined: 22 Feb 2008 Posts: 7 Location: Rome, Italy
|
|
|
|
| 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 |
|
 |
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|