using icetool sort records whose position is not fixed



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

using icetool sort records whose position is not fixed

Postby Surabhi » Fri Sep 11, 2015 6:03 pm

I need to select records that match my parm,
For eg:
My parm will be "abc" or "#abc#"
My input file is
#123#abc#myfirstday#
#12345#abc#myfirstday#
#12#abc#myfirstday#
#12346789#xyz#myfirstday#
#1231234564#xyz#myfirstday#
#12367#abc#myfirstday#
#1233#xyz#myfirstday#
From this I want only those records which contain #abc#.
My problem is as the position of # is not fixed and the # is occuring more than once how do I select only the required records?
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: using icetool sort records whose position is not fixed

Postby BillyBoyo » Fri Sep 11, 2015 6:08 pm

You use PARSE to isolate the data. One dummy PARSEd field for the first, then STARTAT=C'#' and ENDAT=C'#' and you will have your field to test in that second PARSEd field.

If you have lots of data, you could probably cut down on processing by specifying an INCLUDE COND= using a field-type of SS for your '#abc#'.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: using icetool sort records whose position is not fixed

Postby Surabhi » Fri Sep 11, 2015 6:22 pm

i did try using,
INREC PARSE=(%00=(STARTAT=C'#',ENDAT=C'#',FIXLEN=3)),
but the out put im getting is--
#12
#12
#12 and so on....
itz taking the first # instead of second #.
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: using icetool sort records whose position is not fixed

Postby Surabhi » Fri Sep 11, 2015 6:29 pm

i have also tried,
the below mention pgm----
//S1 EXEC PGM=ICETOOL,
// PARM=('JP1"&JOBNM"')
//SYMNAMES DD *
JOBN,6,3,CH
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYMNOUT DD SYSOUT=*
//IN DD DSN=myinput.file1,DISP=OLD
//T1 DD DSN=myoutput.file2,DISP=OLD
//RPT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
/*
//CTL1CNTL DD *
INCLUDE COND=(JOBN,EQ,JP1)
/*
for this the only output i get is the first record
#123#abc#myfirstday#
as i have mentioned the start point as 6.

could you please suggest how do i work around this pgm to get the required output?
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: using icetool sort records whose position is not fixed

Postby BillyBoyo » Fri Sep 11, 2015 7:07 pm

  OPTION COPY
                                 
  INREC PARSE=(%=(ENDBEFR=C'#'),
               %00=(STARTAT=C'#',
                    ENDAT=C'#',
                    FIXLEN=05)),
        BUILD=(%00)


The % on its own in a PARSE is a "dummy" field, which can be used as many times as necessary, and its purpose is just to move the pointer along to the correct position. Since it can't ENDBEFR the first position in the data, it gets to the they byte in front of the second "#".

Then a simple STARTAT and ENDAT with a length of five (not three) gets you the second delimited field (and its delimiters).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: using icetool sort records whose position is not fixed

Postby BillyBoyo » Fri Sep 11, 2015 9:23 pm

From your title I've been assuming you wanted to SORT on the second column.

If you only want to select the records, you could just consider the INCLUDE with SS that I mentioned. You do have to be certain that there will be no "false hits" when you have more realistic data. The #s bounding the field will help, but you have to be sure no other field could contain the same value.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: using icetool sort records whose position is not fixed

Postby Surabhi » Mon Sep 14, 2015 1:46 am

hello,
Your solution did help me out, but i need to sort and copy only records which contain #abc#.
By using the above mention code its sorting all the second coloumn.
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: using icetool sort records whose position is not fixed

Postby Surabhi » Mon Sep 14, 2015 2:17 am

hello,
this is my input file---------
#123#ABC#myfirstday#
#12345#ABC#myfirstday#
#12#ABC#myfirstday#
#12346789#xyz#myfirstday#
#1231234564#xyz#myfirstday#
#12367#ABC#myfirstday#
#1233#xyz#myfirstday#

this is my code----
// SET JOBNM='ABC'
//S1 EXEC PGM=ICETOOL,
// PARM=('JP1"&JOBNM"')
//SYMNAMES DD *
JOBN,6,3,CH
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYMNOUT DD SYSOUT=*
//IN DD DSN=TESTAEN.SXP0213.MYINUPT.FILE1,DISP=OLD
//T1 DD DSN=TESTAEN.SXP0213.MYOUTPUT.FILE2,DISP=OLD
//RPT DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(T1) USING(CTL1)
/*
//CTL1CNTL DD *
INCLUDE COND=(JOBN,EQ,JP1)
/*
**************************** Bottom of Data **********

this is my ouptput-----
#123#ABC#myfirstday#

but i want want the output as-----

#123#ABC#myfirstday#
#12345#ABC#myfirstday#
#12#ABC#myfirstday#
#12367#ABC#myfirstday#

please suggest changes in the code.
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time

Re: using icetool sort records whose position is not fixed

Postby BillyBoyo » Mon Sep 14, 2015 12:15 pm

OK, you have to be careful with your terms. You don't want to sort the data, you want to extract the data which means a certain criteria.

data-to-search,1,lengthoffield1plusfive,SS


or

data-to-search,1,lengthoffield1plusfive



  INCLUDE COND=(data-to-search,EQ,JP1) 


or

  INCLUDE COND=(data-to-search,SS,EQ,JP1)


Which are both the same as:
  INCLUDE COND=(1,15,SS,EQ,JP1)


There's only one potential problem with this, and that is your data. I suggested using the length of the first part of the data plus five (the length you are matching to) for two reasons: avoiding a "false hit"; performance.

If it is possible that the data after the second field could match to something you want, then you should add the PARSE, temporarily include the PARSEd field on the record and use OUTFIL with INCLUDE= to filter further and BUILD to remove the parsed field.

The SS is a type which allows for a sub-string search.

You can specify it on the symbol, or leave the data-type off the symbol and specify it in the INCLUDE, whichever you and your colleagues feel is clearer.

You don't need any other code than the COPY and the INCLUDE.

For this task you don't need to use ICETOOL. SORT itself will be entirely sufficient. Just use the control cards you have in the USING file as your SORTIN.

Good to see you using symbols/SYMNAMES.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: using icetool sort records whose position is not fixed

Postby Surabhi » Fri Sep 18, 2015 6:10 pm

Thanks alot for the solution :)
Surabhi
 
Posts: 49
Joined: Thu Sep 10, 2015 7:51 pm
Has thanked: 4 times
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post