View previous topic :: View next topic
|
Author |
Message |
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Why is your disposition on OUT1 SHR when it should be MOD? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
In your initial post, you said you wanted 15,20 from the second file. That is six records. |
|
Back to top |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
narasimha_devi Warnings : 1 New User
Joined: 10 Mar 2005 Posts: 26
|
|
|
|
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 |
|
|
|