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

Omit Records with DFSORT


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

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Mon Apr 18, 2005 8:55 pm
Reply with quote

Hi Guys, a new topic to discuss about.

I have a dataset ANDYCOOL.TEST.DATA

This dataset is an output for a job and contains some data like:
========ANDYCOOL.TEST.DATA========
cols: 123456789123456
270780078203042
165780078203043
153780078203044
241780078203045
===============================
Here, in the data given above, the First 3 chars and Last 6 chars are of significance to me.
Now, i want to write a pgm which shud do the following:

1. Take the input: first 3 chars and last 6 chars. (eg:- 165 203043)
2. Search the dataset ANDYCOOL.TEST.DATA for the record with this input (eg:- rec 2 from above data will be selected)
3. Omit all other records from the dataset except the one selected.
4. Final output shud be ANDYCOOL.TEST.DATA with only selected record
that is:
========ANDYCOOL.TEST.DATA========
cols: 123456789123456
165780078203043
===============================

Please let me know how shud i structure the program as well as the
JCL

Thanks in advance,
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 Apr 18, 2005 9:19 pm
Reply with quote

Do you really want to write a program? If not, then you could use the following DFSORT job to do this:


Code:

//S1  EXEC  PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(1,3,CH,EQ,C'165',AND,10,6,CH,EQ,C'203043')
/*
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Mon Apr 18, 2005 9:38 pm
Reply with quote

I want this to make up a Utility that can be used by other programers.

Only thing they shud do is give the input data in some dataset and leave all to the pgm.
Your JCL idea is very nice, but from point of view of a user, playin with the JCLs wont be a gr8 idea.

pgm shud be like:
1. Take the data to be searched from 1 dataset.
2. Search this in ANDYCOOL.TEST.DATA
3. If data found omit others and keep only the selected record.

In this case there'll be two input DDs and one output DDs.

See if you are getting my point.
However, Very much thanks for your input and showing your interest. It is very helpful.
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 Apr 19, 2005 1:22 am
Reply with quote

DFSORT is a utility that can be used by other programmers.

There are several ways to do what you want, depending on what the data to be searched in the separate input data set can look like. For example, you could make the data to be searched DFSORT symbols like in this job:

Code:

//S1  EXEC  PGM=ICEMAN
//SYMNAMES DD *
Targ1,'165'
Targ2,'203043'
/*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  INCLUDE COND=(1,3,CH,EQ,Targ1,AND,10,6,CH,EQ,Targ2)
/*


You can use any symbol names you like instead of Targ1 and Targ2.

Or if you want the data to be searched in the separate data set to look like this:

//SEARCH DD *
165 203043
/*

that could be done with DFSORT as well.

But if you feel that you need to reinvent the wheel by writing your own program, that's your call.
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Tue Apr 19, 2005 7:19 pm
Reply with quote

Thanks Frank,
This solution is quite feasible. This shud solve my purpose.

Juss one more doubt:
You asked to use the DFSORT..but in the above code that you have presented..u have used ICEMAN. What exactly is this ICEMAN utility..has it anything to do with the DFSORT?
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 Apr 19, 2005 8:25 pm
Reply with quote

ICE is the IBM three-character id for DFSORT, so DFSORT's modules, messages, etc use ICE. ICEMAN is DFSORT's entry point. However, the other sort products have chosen to make ICEMAN and SORT entry points for their products as well. So when you use PGM=ICEMAN or PGM=SORT, you invoke the primary sort product installed at your site. That could be DFSORT, or it could be one of the other products.

Dude ... Could you please do everyone a favor and use regular English instead of abbreviations, e.g. use "should" instead of "shud", "don't worry" instead of "Dun wry", "you" instead of "u", etc. The abbreviations are sometimes hard to understand, especially for us "older" dudes. Thanks.
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Wed Apr 20, 2005 9:41 pm
Reply with quote

No problem boss.
I ll take care hens4th ;)

Thanks for your input Guys...it was very helpful..!
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Sun Apr 24, 2005 11:05 am
Reply with quote

Hey Frank,
The solution that you have given above about using the TARG1 and TARG2 can just be limited to one search at a time.
Suppose if i want to search and maintain 2 or more of such records like:
========ANDYCOOL.TEST.DATA========
cols: 123456789123456
165780078203043
241780078203045
===============================
what will i have to do? Can i use it like this:

//S1 EXEC PGM=ICEMAN
//SYMNAMES DD *
Targ1,'165'
Targ2,'203043'
/*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,3,CH,EQ,Hse1,AND,10,6,CH,EQ,Ord1)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,3,CH,EQ,Hse2,AND,10,6,CH,EQ,Ord2)
/*

Please correct me if i am wrong.

Bottomline: The search and omit shud not be limited to juss one record at a time.
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 Apr 25, 2005 4:10 am
Reply with quote

You can have many symbols in SYMNAMES. You can have many relational conditions in an INCLUDE statement. If you want to search for the records containing the values Hse1 and Ord1, or Hse2 and Ord2, you can do it like this:

Code:

//S1  EXEC  PGM=ICEMAN
//SYMNAMES DD *
Hse1,'165'
Ord1,'203043'
Hse2,'241'
Ord2,'203045'
/*
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN DD *
  OPTION COPY
  INCLUDE FORMAT=CH,
     COND=((1,3,EQ,Hse1,AND,10,6,EQ,Ord1),OR,
         1,3,EQ,Hse2,AND,10,6,EQ,Ord2))
/*


If that's not what you want to do, then please explain more clearly what you want to do.
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Tue Apr 26, 2005 5:40 pm
Reply with quote

Thanks Frank,
This is what i wanted.

Please tell me wht i am interpreting is right or wrong

In the condition :
1,3,EQ,Hse1,AND,10,6,EQ,Ord1 ..does it mean

From first upto third character equal to Hse1 AND From tenth upto sixteenth character equal to Ord1.

If this is right my doubt is, where does the Omit condition comes into picture. Is it that By default "SORT" removes all the records except the one matched with the above condition?

Thanks in advance,
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 Apr 26, 2005 9:46 pm
Reply with quote

Yes, 1,3 means positions 1-3. 1 is the starting position and 3 is the length.

10,6 means positions 10-15. 10 is the starting position and 6 is the length.

INCLUDE keeps all of the records that match the given condition and deletes all of the records that do not match the given condition.

OMIT deletes all of the records that match the given condition and keeps all of the records that do not match the given condition.

If you're not familiar with DFSORT and ICETOOL, I'd suggest going through "z/OS DFSORT Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access Getting Started, and all of the other DFSORT books, from:

Use [URL] BBCode for External Links
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Tue Apr 26, 2005 10:24 pm
Reply with quote

Thanks Man,
This has been really helpful.
I thank all you guys for your inputs.
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Tue Apr 26, 2005 10:43 pm
Reply with quote

Hi again,
Continuing with my doubts, juss have some more of 'em(Please dun pull ur hair):

I have a dataset ANDYCOOL.TEST.DATA
It contains some wierd data wch actually i dun understand.
My only concern is, i need to find a 6 character string in that dataset.

For instance:
=========ANDYCOOL.TEST.DATA===========
asasasasasasassasasasaaaasasasaaaasaaasasaasasa
asasasasasasassasasasaaaasasasaaaasaaasasaasasa
asasasasasasassasasas123456sasaaaasaaasasaasasa
asasasasasasassasasasaaaasasasaaaasaaasasaasasa
asasasasasasassasasasaaaasasasaaaasaaasasaasasa
===================================

Yaa..its something like given above. Now, how do i find the string "123456" in the above dataset. Mind you, there is no fixed cloumn or row whr the string will appear everytime.
From the above posts i understand i'll have to use the ICEMAN tool, but how do i modify it to meet the requirement.

Regards and Thanks in Advance,
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 Apr 26, 2005 11:40 pm
Reply with quote

Quote:
I thank all you guys for your inputs.


All what guys? So far, it's just you and me here, buddy. icon_lol.gif

You can use DFSORT's SS (substring search) format in INCLUDE to output the record that contains the string as follows:

Code:

   INCLUDE COND=(1,n,SS,EQ,C'123456')


where n is the length of the record (e.g. 80).

Is that what you want to do?
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Wed Apr 27, 2005 4:04 pm
Reply with quote

Yes Buddy,
This is what is wanted. I'll try it out. If it worked fine, thanks to you,
...if not, you are in trouble, cuz am goin to ask you lots and lots of doubts ;)

I am verymuch thankful to you Frank for handholding me till here, :)

Regards,
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 Apr 27, 2005 8:32 pm
Reply with quote

Glad I could help.
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Wed Apr 27, 2005 10:37 pm
Reply with quote

Hi Frank,
I used the below code to search the string and to delete the remaining records in a dataset:
==========================
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file
//SORTOUT DD DSN=... output file
//SYSIN DD *
OPTION COPY
INCLUDE COND=(1,3,CH,EQ,C'165',AND,10,6,CH,EQ,C'203043')
/*
==========================

The problem i faced with this is, it was working fine when the Input and the output datsets were "FB" ie fixed block.
When i tried to do this by datasets with "VB" ie variable block, the job executed successfully, but the output was coming empty, even though the record existed with that condition.

The Input and Output dataset are goin to be "VB" as per my requirement.
Is it that the ICEMAN or SORT utilities dun wrk with the VB datasets? or
I am missing something above?

Please let me know.
Thanks in Advance.
Regards,
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 Apr 28, 2005 12:10 am
Reply with quote

Yes, DFSORT can work with VB data sets, but you have to use the correct starting positions. VB records have an RDW in positions 1-4, so the data starts in position 5, not in position 1 as for FB records. Thus, you have to add 4 to your starting positions in the INCLUDE statement to account for the RDW.

Code:

  INCLUDE COND=(5,3,CH,EQ,C'165',AND,14,6,CH,EQ,C'203043')
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Thu Apr 28, 2005 2:50 pm
Reply with quote

Hi Frank,
Your solution as usual worked properly. I was able to get the required data in the output datatset. Thanks for this.

If you remeber somewhere in this thread i had asked you about just searching a string in the datafile. You had suggested me of using the SS substring: INCLUDE COND=(5,3,SS,EQ,C'290'). I used the below code:
=========
/*
//SEARCH EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=.........INPUT,DISP=SHR
//SORTOUT DD DSN=.......OUTPUT,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSALLDA,
// SPACE=(TRK,(150,5),RLSE),
// DCB=(LRECL=2015,BLKSIZE=23476,RECFM=VB)
//SYSIN DD *
OPTION COPY
INCLUDE COND=(5,3,SS,EQ,C'290')
/*
==============================
Using this i got the selected record in the output dataset just like i got it after using the "INCLUDE COND=(12,3,CH,EQ,C'290'). I dont want it that way.

What i want it is:
1. Search for the string in the Variable Block dataset.
2. If found execute the next step in job.
3. If not found terminate the job.

Please tell me how can i do this.
Thanks in Advance.
Regards,
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 Apr 28, 2005 9:27 pm
Reply with quote

Quote:
INCLUDE COND=(5,3,SS,EQ,C'290')


Yes, in this case SS is equivalent to CH because your field and constant are the same length (3). Here's an example of using SS where it isn't equivalent to CH:

Code:

  INCLUDE COND=(5,25,SS,EQ,C'290')


In this case, we will search for '290' anywhere between positions 5 and 29.

Quote:
What i want it is:
1. Search for the string in the Variable Block dataset.
2. If found execute the next step in job.
3. If not found terminate the job.



I need answers to the following questions before I can tell you how to do this:

1) Are you using z/OS DFSORT V1R5 or DFSORT R14? The ICE000I message from a DFSORT run will tell you which one you're using. Let me know. If you can't tell, post the //SYSOUT messages from a PGM=SORT run.
2) What is the LRECL of your input file?
3) I can show you how to set a return code of zero or non-zero depending on whether the string was found or not. You could use the return code to control subsequent steps. Is that what you mean by 2 and 3?
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Thu Apr 28, 2005 9:42 pm
Reply with quote

Hi Frank,
The is the actual input file:
===============DEVELOPMENT.READ.INPUT==RECFM=VB====
This order has been processed and the following terms are applicable to
it.
Collect the order by CARRIER.
Collect on Person.
Auto send and allow Ship Charge.
Please follow up with the source person for your shipment 143246...
For further details contact helpdesk. Thank You .
=============================================

My concern is i need to find the string "143246" in the whole dataset. Thats what i meant by 1

You have correctly got the points 2 and 3.
For the input required to you i'll try to get back asap.

Thanks dude,
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Fri Apr 29, 2005 11:06 am
Reply with quote

Hi Frank,

The LRECL of my input file is INPUT LRECL = 2015, BLKSIZE = 23476, TYPE = VB.
The LRECL of my output file is also kept as OUTPUT LRECL = 2015, BLKSIZE = 23476, TYPE = VB.

My sort version is DFSORT REL 14.0...got this fromt the sysout of one of the sort runs as you said.
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: Fri Apr 29, 2005 9:06 pm
Reply with quote

With DFSORT R14, you can use this DFSORT/ICETOOL job to do what you want. The step will give you a return code of 0 if the string is found, or a return code of 12 if the string isn't found.

Code:

//R14   EXEC  PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=...  input file (VB/2015)
//OUT DD DSN=...  output file (VB/2015)
//TOOLIN DD *
* Look for '143245' string.
  COPY FROM(IN) TO(OUT) USING(CTL1)
* If string found, set RC=0.
* If string not found, set RC=12.
  COUNT FROM(OUT) EMPTY
/*
//CTL1CNTL DD *
  OPTION COPY,VLSCMP
  INCLUDE COND=(1,2015,SS,EQ,C'143246')
/*


The job above would work with z/OS DFSORT V1R5 as well, but with the new release you can actually do this a little more easily by using the new NULLOUT parameter. The step will give you a return code of 0 if the string is found, or a return code of 16 if the string isn't found.

Code:

//V1R5  EXEC  PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VB/2015)
//SORTOUT DD DSN=...  output file (VB/2015)
//SYSIN DD *
* Look for '143245' string.
  INCLUDE COND=(1,2015,SS,EQ,C'143246')
* If string found, set RC=0.
* If string not found, set RC=16.
  OPTION COPY,VLSCMP,NULLOUT=RC16
/*
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Fri Apr 29, 2005 10:03 pm
Reply with quote

Hey Frank,
Thanks for the solution once again. I'll try this and get back to you.

Thanks again !
Regards,
Back to top
View user's profile Send private message
andycool

New User


Joined: 12 Apr 2005
Posts: 64

PostPosted: Mon May 02, 2005 5:55 pm
Reply with quote

Hi Frank,
This solution worked fine. Thanks for your help.

I have a new query, a bit different, i'll try to explain it to you.

1. I have chained three jobs Job1, Job2 and Job3
Job1 is submitted which at the end if the maxcc of Job1 = 0 will submit Job2 and so on. I have set this up and currently it is working fine.

2. Now, in job1 there is a condition as illustrated below:
-----------------------------------------------------------------------------------
=========JOB1========
job1step1
job1step2
job1step3
i am searching for a string '123456' in a dataset JOB1.OUTPUT at this step.
job1submit
If string is found submit the next job that is Job2.
(this is wrking fine currently..no issue here)
=========JOB2========
job2step1
job2step2
job2step3
i am searching for a string '123456' in a dataset JOB2.OUTPUT at this step.
job2submit
If string is found submit the next job that is Job3.
(this is also wrking fine currently..no issue here)
-------------------------------------------------------------------------------------

The Issue:
1. The string '123456' is actually a transaction number which is processed in this chain of three jobs.
2. This can be any 6 digit number. Every time while running this chain that i have made, i have to enter this string in the INCLUDE statement in ICETOOL used for searching in each job.
Like : open the job JOB1 and give the string in its include statement, open job JOB2 and give the same string in the INCLUDE statement and so on for JOB3 also.

The Question:

Is there anyway i can point the INCLUDE statemnt of next job to the INCLUDE statemnt for the first job?
Like : open the job JOB1 and give the string in its include statement, point the INCLUDE statmnt of job2 to that of job1 so that i dun have to repreatedly enter the same string for job2 and job3 ?

Bottomline: Something like the "referback technique"

Please let me know if the doubt is clear,
Thanks in Advance,
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
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 Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top