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
 

 

OMIT/INCLUDE records with N consecutive characters

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: OMIT/INCLUDE records with N consecutive characters
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 Moderator


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

PostPosted: Thu Oct 18, 2007 9:42 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Oct 22, 2007 9:01 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Tue Oct 23, 2007 10:55 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Wed Oct 24, 2007 9:11 pm    Post subject:
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    Post subject:
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    Post subject:
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    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 Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


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