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

DFSORT - Retrieve selective records from 2 input files


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

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Thu Aug 06, 2015 4:12 pm
Reply with quote

Hi,

I have 2 input files. I need to copy 1-10 records from INFILE1 and 15-20 records from INFILE2 to OUTFILE. Now the OUTFILE will contain the 10 records of INFILE1 and 5 records of INFILE2.

I tried the below code.
Code:

//TOOL EXEC PGM=ICETOOL                               
//IN1 DD DSN=INFILE1,DISP=SHR                         
//IN2 DD DSN=INFILE2,DISP=SHR                         
//OUT1 DD DSN=OUTFILE,DISP=SHR                         
//TOOLMSG DD SYSOUT=*                                 
//DFSMSG DD SYSOUT=*                                   
//TOOLIN DD *                                         
  SUBSET FROM(IN1) TO(OUT1) INPUT KEEP RRN(1,10)       
  SUBSET FROM(IN2) TO(OUT1) INPUT KEEP RRN(11,5)       
/*                                                     


But the output file contains only the 5 records from the INFILE2.

Please let me know correct code.
Back to top
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Thu Aug 06, 2015 4:53 pm
Reply with quote

Why is your disposition on OUT1 SHR when it should be MOD?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 06, 2015 5:01 pm
Reply with quote

To have the same output dataset for two ICETOOL operations in the same step, you will need DISP=MOD, as superk has pointed out. You will also need your output dataset to be empty, or to not exist, before the step starts, else the DISP=MOD will add to existing data.
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Thu Aug 06, 2015 5:40 pm
Reply with quote

Bill Woodger wrote:
To have the same output dataset for two ICETOOL operations in the same step, you will need DISP=MOD, as superk has pointed out. You will also need your output dataset to be empty, or to not exist, before the step starts, else the DISP=MOD will add to existing data.


I have the Empty OUTFILE and tried with DISP=MOD.

INFILE1 Contains
Code:

11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
11111111111111111111111111111
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222
22222222222222222222222222222


INFILE2 Contains
Code:

3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444
4444444444444444444444444444


After coding DISP=MOD OUTFILE contains
Code:

1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
1111111111111111111111111111
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
3333333333333333333333333333
4444444444444444444444444444


But this is not the excepted output. Not sure where i went wrong.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 06, 2015 6:00 pm
Reply with quote

You need to read the manual more closely to understand what RRN is doing for you.

You think it is saying "record 11 and subsequent records until the total is five". What it is saying is "records from number 5 to number 11, inclusive".

RRN(11,5) and RRN(5,11) produce the same output. From the lowest number, to the highest number, inclusive.

You need 11,15 (or 15,11).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 06, 2015 6:17 pm
Reply with quote

In your initial post, you said you wanted 15,20 from the second file. That is six records.
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Thu Aug 06, 2015 6:26 pm
Reply with quote

Bill Woodger wrote:
You need to read the manual more closely to understand what RRN is doing for you.

You think it is saying "record 11 and subsequent records until the total is five". What it is saying is "records from number 5 to number 11, inclusive".

RRN(11,5) and RRN(5,11) produce the same output. From the lowest number, to the highest number, inclusive.

You need 11,15 (or 15,11).


Thanks Bill. Your explanation make sense.

Is there any simple way to handle my requirement.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Aug 06, 2015 6:56 pm
Reply with quote

Quote:
Is there any simple way to handle my requirement.


just explain the meaningless remark ...

You were told to use DISP=MOD and it worked,
It was clarified Your MISwording about the number of records to be extracted

what else are You looking for ???
Back to top
View user's profile Send private message
narasimha_devi
Warnings : 1

New User


Joined: 10 Mar 2005
Posts: 26

PostPosted: Thu Aug 06, 2015 7:35 pm
Reply with quote

enrico-sorichetti wrote:
Quote:
Is there any simple way to handle my requirement.


just explain the meaningless remark ...

You were told to use DISP=MOD and it worked,
It was clarified Your MISwording about the number of records to be extracted

what else are You looking for ???


I overlooked Bill's last post that's why asked for alternate, thinking that my code was in accurate. It is working fine. Thanks Bill.

Sorry Enrico;
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 TRIM everything from input, output co... DFSORT/ICETOOL 1
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top