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

OMIT/INCLUDE records with N consecutive characters


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
szbhattacharjee

New User


Joined: 12 Oct 2007
Posts: 4
Location: Hyderabad

PostPosted: Thu Oct 18, 2007 9:27 pm
Reply with quote

I’m using following sort card to omit records with 4 consecutive A's from the input file:
Code:
//SORTIN   DD *                 
 00003AAAABBBB                 
 00002AAAABBBB                 
 00001BBBBBBBB                 
 00007BBBBBBBB                 
 00005CCCCBBBB                 
//SORTOUT  DD SYSOUT=*         
//SYSIN    DD *                 
  OMIT COND=(7,4,CH,EQ,C'AAAA')
  OPTION COPY                   
/*     


I tried obtaining the same output by using following sort card, but it gave a syntax error:
Code:
//SYSIN    DD *               
  OMIT COND=(7,4,CH,EQ,4C'A')
  OPTION COPY                 
/*


Is there any way (in DFSORT) to OMIT/INCLUDE records with N consecutive characters?

Thanks.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Oct 18, 2007 9:42 pm
Reply with quote

Quote:
OMIT COND=(7,4,CH,EQ,4C'A')


4C'A' is not valid syntax for the OMIT statement.

Obviously, it's no big deal to type in C'AAAA'. How large an N are we talking about here?
Back to top
View user's profile Send private message
szbhattacharjee

New User


Joined: 12 Oct 2007
Posts: 4
Location: Hyderabad

PostPosted: Mon Oct 22, 2007 9:58 am
Reply with quote

Frank,
I've a requirement to OMIT records with 167 consecutive zeros starting at byte position 1013 in the input file. Please suggest if there is a better way of writing this sort card. Thanks.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Mon Oct 22, 2007 10:28 am
Reply with quote

szbhattacharjee
This SORT JOB would OMIT all the records with 167 consecutive 0's from the position 1013.
Code:
//*******************************************************               
//OMIT0    EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD I/P FILE                                                 
//SORTOUT  DD O/P FILE                                                 
//SYSIN    DD *                                                         
           SORT FIELDS=COPY                                             
           INCLUDE COND=(1013,167,ZD,NE,0)                             
/*                                                                     
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Oct 22, 2007 9:01 pm
Reply with quote

Quote:
I've a requirement to OMIT records with 167 consecutive zeros


If you mean character zeros (e.g. '0's), then you can use Krisprems INCLUDE statement, although I would use this OMIT statement to match your description better:

Code:

    OMIT COND=(1013,167,ZD,EQ,0)
Back to top
View user's profile Send private message
szbhattacharjee

New User


Joined: 12 Oct 2007
Posts: 4
Location: Hyderabad

PostPosted: Tue Oct 23, 2007 6:40 pm
Reply with quote

Frank and krisprems thanks for your responses. Indeed your sort card would solve my present problem.
I also wanted to learn a generic way to OMIT or INCLUDE records based on pattern of N consecutive characters in the input file. Often we have requirements where a record is omitted if there are N consecutive A's (B's or C's or '9' or AB's...) starting at particular position.
Please suggest if we can have generic sort card for these requirements.
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Tue Oct 23, 2007 10:28 pm
Reply with quote

szbhattacharjee
This SORT JOB in the first step creates an SYMNAMES with 10 consecutive A's
In the second step using the SYMNAME-CHECK_FOR you will be including only the records which have 10 consecutive A's in the position 5
Code:
//CRESYMN  EXEC PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD *                                                         
 CHECK_FOR,C'                                                           
/*                                                                     
//SORTOUT  DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INREC  OVERLAY=(14:10C'A',X'7D')                                     
/*                                                                     
//OMIT     EXEC PGM=ICEMAN                                             
//SYSOUT   DD SYSOUT=*                                                 
//SYMNAMES DD DSN=&&TEMP1,DISP=(MOD,PASS),SPACE=(TRK,(5,5)),UNIT=SYSDA 
//SORTIN   DD *                                                         
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                 
 AAAAAAQFRSGDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                 
 AAAAAAAAAAAAFGHJGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                 
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                 
 AAAASD123445AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                 
/*                                                                     
//SORTOUT  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  INCLUDE COND=(5,10,CH,EQ,CHECK_FOR)                                   
/*                                                                     

Final, SORTOUT
Code:
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                         
 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA                         
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Oct 23, 2007 10:55 pm
Reply with quote

Note that the technique shown by Krisprems to use a Symbol will only work for up to 64 characters since that's the limit for the length of a Symbol constant. So it won't work for your example of 167 repeating characters.

What would work is to use INREC to append the repeating constant to the end of each record and compare the field to it. For example, if your input file has RECFM=FB and LRECL=2000 and you want to compare a field starting in position 1013 to 167 A's, you could use these DFSORT control statements:

Code:

  OPTION COPY
  INREC OVERLAY=(2001:167C'A')
  OUTFIL INCLUDE=(1013,167,CH,EQ,2001,167,CH),
     BUILD=(1,2000)
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Oct 24, 2007 9:16 am
Reply with quote

If in case we have to search for a string without knowing the position, may be we can accomplish like this
Code:
OPTION COPY                                                           
  INCLUDE COND=(1,<LRECL>,SS,EQ,CHECK_FOR) 


But frank, how a substring search can be in your case. If we could do that, then it would be a very helpful trick for us. icon_exclaim.gif


Quote:
Note that the technique shown by Krisprems to use a Symbol will only work for up to 64 characters since that's the limit for the length of a Symbol constant.

I was neither aware/nor thouhgt of limits, thanks for letting us know.

Quote:
So it won't work for your example of 167 repeating characters.

I think we can, For example if we have to check for a string of 100 A's in 1st position, the we can build an SYMNAMES having 50 A's
Code:
CHECK_FOR,C'AAAA.....A'


In the include cond
Code:
INCLUDE COND=(1,50,CH,EQ,CHECK_FOR,&,51,50,CH,EQ,CHECK_FOR)

I know this is tedious compared to your solution but just a thought icon_idea.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Oct 24, 2007 9:11 pm
Reply with quote

Quote:
If in case we have to search for a string without knowing the position, may be we can accomplish like this Code:

OPTION COPY
INCLUDE COND=(1,<LRECL>,SS,EQ,CHECK_FOR)

But frank, how a substring search can be in your case. If we could do that, then it would be a very helpful trick for us.


Since a substring search requires a constant, my method of creating a field with 167A's wouldn't work for substring search (but that wasn't what the OP asked for).

You could "generate" an INCLUDE statement with the required constant in one step and use that in SYSIN of another step, but the constant wouldn't fit on one line so you'd have to be careful to get the continuation syntax right.

Code:

  INCLUDE COND=(1,50,CH,EQ,CHECK_FOR,&,51,50,CH,EQ,CHECK_FOR)


Yes, you could do that kind of thing with Symbols. Of course, for 167A's it would require a 64 character symbol (used twice) and a 39 character symbol. That's not too bad if you can hardcode the lengths, e.g.

Code:

...
//SORTIN DD *
RECORD
...
//SYSIN DD *
  OPTION COPY
  OUTFIL BUILD=(C'C64,''',64C'A',C'''',80:X,/
    C'C39,''',39C'A',C'''')
/*


would generate the following symbols:

Code:

C64,'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
C39,'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'                     


Then you could use:

Code:

  INCLUDE COND=(1,64,CH,EQ,C64,AND,
     65,64,CH,EQ,C64,AND,
     129,39,CH,EQ,C39)
Back to top
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Oct 24, 2007 9:35 pm
Reply with quote

Quote:
Since a substring search requires a constant, my method of creating a field with 167A's wouldn't work for substring search

OK

Quote:
(but that wasn't what the OP asked for).
yes that's true, but was thinking of some general scenario's, so that could learn from u icon_razz.gif

Thanks a lot for your time frank icon_super.gif
Back to top
View user's profile Send private message
szbhattacharjee

New User


Joined: 12 Oct 2007
Posts: 4
Location: Hyderabad

PostPosted: Thu Oct 25, 2007 9:54 am
Reply with quote

Frank and Krisprems,
I tried all your solutions with some more permutations and combinations from my side. I'm overwhelmed icon_super.gif by the results of all these sort cards.

Thanks a lot.
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Reading dataset in Python - New Line ... All Other Mainframe Topics 22
Search our Forums:

Back to Top