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

Deleting records from input.


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

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 12:41 pm
Reply with quote

hI,

I am having an input file of lrecl 100.

My requirement is like :-

If from position no 5 to 7 is equal to CUW then it will delete all the corresponding records (whose 5th to 7th value = CUW) from the input file and put it in some output records and the input will contain the records where the value is not CUW.

I suppose i m clear with my question.

Could anybody send me the sort card for this.
Back to top
View user's profile Send private message
srinivas_cog

New User


Joined: 05 Jun 2008
Posts: 17
Location: chennai

PostPosted: Tue Sep 23, 2008 12:59 pm
Reply with quote

You want the records in output file which are not having 5th to 7th value = CUW-- Is this right. If so then use

Code:

  SORT FIELDS=COPY
  OMIT COND=(5,3,CH,EQ,C'CUW')
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 1:04 pm
Reply with quote

Hi srini,

This is done.
But i want the records which are going to write in the output should be deleted from the input also. Here it is not effecting anything on the onput file.

So how can i achieve that ???
Back to top
View user's profile Send private message
srinivas_cog

New User


Joined: 05 Jun 2008
Posts: 17
Location: chennai

PostPosted: Tue Sep 23, 2008 1:11 pm
Reply with quote

Not clear what you are asking .. Please provide input file and required output file.
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 1:21 pm
Reply with quote

Hi,
For example let the input file name is INP1 and OUTput name is OUT1


INP!

A RECORD OF 900
The RECORD On 700
A value of 500


I need the output as ,
OUT1

A RECORD OF 900
The RECORD On 700

and these two records should be deleted from the INP1
means after the job runned successfully, the inp1 shoul contain only A value of 500. and the OUT1 as showned above.

Here i m checking with RECORD positions as a condition i.e (3 to 8)

I suppose this time i m clear to u ???
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Sep 23, 2008 1:25 pm
Reply with quote

Why do you want to overwrite the input file ?

What is wrong with creating a new file as shown which only contains the data that you want - and then use that file in further processes.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Sep 23, 2008 1:28 pm
Reply with quote

Hi,

try this

Code:
//SELECT2  EXEC PGM=SORT                                               
//SYSOUT   DD SYSOUT=*                                                 
//SORTIN   DD DSN=CSCSGLC.FF,DISP=SHR                                   
//SORTOUT  DD DSN=CSCSGLC.FF,DISP=SHR                                   
//DISCARD  DD SYSOUT=*                                                 
//SYSIN    DD *                                                         
  OPTION COPY                                                           
  OUTFIL FNAMES=SORTOUT,                                               
       INCLUDE=(5,3,CH,NE,C'CUW')                                       
  OUTFIL FNAMES=DISCARD,SAVE                                           
/*                                                                     
//*                                                                     


I hope you have a backup of the input file.


Gerry
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 1:37 pm
Reply with quote

Hi Gerry,

Sorry i am not getting the output.

I am searchinhg in some of the books. please let me know if u got the answer.
Back to top
View user's profile Send private message
srinivas_cog

New User


Joined: 05 Jun 2008
Posts: 17
Location: chennai

PostPosted: Tue Sep 23, 2008 1:52 pm
Reply with quote

Hi,

You will get the required output in SORTOUT data set(i.e same file name as input).
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 2:00 pm
Reply with quote

Hi srini,

Simply i am having an input file which need to be enter to the sort card, that will produce an output in a new DS(Depending upon above posted conditions) along with that the records present in the resultant output should be deleted from the input file.
Back to top
View user's profile Send private message
srinivas_cog

New User


Joined: 05 Jun 2008
Posts: 17
Location: chennai

PostPosted: Tue Sep 23, 2008 2:20 pm
Reply with quote

Input file :

RECORD1: 1234CUWABCD
RECORD2: 3456CUWABCD
RECORD3: ABCD12344567

in the above records you want first two records in one outfile and those two should be deleted from your input (i.e. third record should present in your input file) ---Is this right??
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 2:37 pm
Reply with quote

Hi srini,

Sorry for late reply.

This time u got my point.

This is exactly what i want.

Could you please help me out ???
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Tue Sep 23, 2008 2:45 pm
Reply with quote

Niki

What are the attributes of your input file - FB or VB ?

This is very important information as it drastically affects the coding of the control statements, and my guess would be that the file is VB as the code supplied by Gerry did not work - according to you.
Back to top
View user's profile Send private message
srinivas_cog

New User


Joined: 05 Jun 2008
Posts: 17
Location: chennai

PostPosted: Tue Sep 23, 2008 2:51 pm
Reply with quote

what ever the solution provided by Gerry will prefectly work if the input file is FB.

Please see that the SORTIN and SORTOUT files are same, in SOROUT you will get the required output and in DISCARD you will get the remaining records.
Back to top
View user's profile Send private message
Niki

Active User


Joined: 20 Sep 2008
Posts: 106
Location: Bangalore

PostPosted: Tue Sep 23, 2008 2:54 pm
Reply with quote

I ll check it out once again.

Thank u all for helping me.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Sep 23, 2008 3:23 pm
Reply with quote

Hi,

this is more for Frank to answer
Quote:
SORTIN and SORTOUT can be the same file for a SORT operation. SORTIN and SORTOUT should NOT be the same file for a COPY operation


In my previous example I used the same file for both SORTIN and SORTOUT and there were no issues.

I have also tested this on a file containing 845518 records with an LRECL of 133 and deleted 110 records without any issues.

I guess my question is why shouldn't we use the same file for a COPY statement ?

and where are the records stored before records they are written to SORTOUT for a COPY operation ?

Is the SORTOUT DD opened after the SORTIN DD has been closed for both COPY and SORT operation ?


Gerry
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 Sep 23, 2008 8:53 pm
Reply with quote

Quote:
what ever the solution provided by Gerry will prefectly work if the input file is FB.

Please see that the SORTIN and SORTOUT files are same, in SOROUT you will get the required output and in DISCARD you will get the remaining records.


DFSORT does NOT support the use of the same data set for SORTIN and SORTOUT for a COPY operation! Gerry's solution is NOT guaranteed to work so it should NOT be used.

Here's the correct way to do what the OP asked for with DFSORT/ICETOOL.

Code:

//S1   EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (modified)
//OUT DD DSN=...  output file
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TOOLIN DD *
* Write 'CUV' records to OUT and non-'CUV' records to T1.
COPY FROM(IN) USING(CTL1)
* Write T1 records to IN.
COPY FROM(T1) TO(IN)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=OUT,INCLUDE=(5,3,CH,EQ,C'CUW')
  OUTFIL FNAMES=T1,SAVE
/*
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 Sep 23, 2008 9:00 pm
Reply with quote

Quote:
guess my question is why shouldn't we use the same file for a COPY statement ?

and where are the records stored before records they are written to SORTOUT for a COPY operation ?

Is the SORTOUT DD opened after the SORTIN DD has been closed for both COPY and SORT operation ?


For a COPY operation, DFSORT opens the SORTIN and SORTOUT data sets in parallel. So it is reads a record from the data set and then writes that record to the same data set. This can result in messing up the data set. It may work sometimes, but it is NOT guaranteed to work. It's risky and should be avoided.

For a SORT operation, DFSORT opens the SORTIN data set, reads all of the records and then closes the SORTIN data set. Then it opens the SORTOUT data set, writes to it and closes it. So there's no parallel processing to mess things up. You can still lose the data set if something goes wrong (e.g. an I/O error) so you should have a backup or avoid doing this.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Sep 24, 2008 6:51 am
Reply with quote

Hi Frank,

thanks for the explanation, actually I tried another test using the same file as input and output, this time the file was on cart and the job abended.

IEC146I 513-04,IFG0194A

04 An OPEN macro instruction was issued for a magnetic tape data
set allocated to a device that already has an open data set on
it. Make sure that the first data set is closed before the
second is opened, or allocate the second data set to a different
device.

Again thanks for clearing this up, is it possible to put some code in DFSORT to fail the job when the same file is used for both SORTIN and SORTOUT.


Gerry
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 Sep 24, 2008 9:28 pm
Reply with quote

Quote:
is it possible to put some code in DFSORT to fail the job when the same file is used for both SORTIN and SORTOUT.


Yes, it's possible, but we're not going to do it because if we did, then somebody would complain that they have been "successfully" using the same file for SORTIN and SORTOUT for years and now it doesn't work. We have warnings in the book, but people can choose to ignore the warnings (for example, if they have a backup) and we don't want to have jobs that were working for them previously fail all of a sudden. (The decisions a developer of a general use product has to make are often more complex than they seem.)
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top