View previous topic :: View next topic
|
Author |
Message |
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi,
I have 2 flat files.I need to replace the contents from one file into another file.
Eg:
File1:
LOG ON
REPLACE
RESUME
(
FIELD1 VARCHAR NULL
FIELD2 CHAR NULL
FIELD3 NUMERIC NULL
)
File2:
LOG OFF
DELETE
RESTART
(
BREAK CHAR NULL
CREATE VARCHAR NULL
)
Outfile:
LOG ON
REPLACE
RESUME
(
BREAK CHAR NULL
CREATE VARCHAR NULL
)
I just need the contents between (...) to be replaced.
Pls let me know if more explanation is reqd.Pls provide a solution thru DFSORT.
Thanks
Aneeta |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
aneeta wrote: |
I just need the contents between (...) to be replaced. |
Are the records between the parentheses always three being replaced by two?
Is the number of records before the opening parentheses always three?
Do any records ever follow the closing parentheses? |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi,
Thanks for the response.The number of records between the parentheses in both the files is not fixed,it varies.There is no record following the closing parantheses.
Thanks
Aneeta |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Is the number of records before the opening parentheses always three? |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi,
No..the number of records before the opening parentheses is not 3..it varies..
Thanks
Aneeta |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Can I get a solution for my requirement thru DFSORT?
Thanks
Aneeta |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Aneeta,
Is the number of records before the '(' record in file1 always the same as the number of records before the '(' record in file2 (e.g. both have 3 records before the '(', or both have 4 records before the '(', etc)?
What is the RECFM and LRECL of the input files? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
aneeta wrote: |
the number of records before the opening parentheses is not 3..it varies. |
aneeta wrote: |
The number of records between the parentheses in both the files is not fixed,it varies. |
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
William,
What is the relevance of the lines you quoted? They don't tell me if the number of lines in file1 before the '(' is always the same as the number of lines in file2 before the '(' or not which is what I want to know. |
|
Back to top |
|
|
ibmmainframesyntel
Active User
Joined: 26 Feb 2007 Posts: 126 Location: Chennai
|
|
|
|
frank sorry to reply for this query....
consider
both the files contains only three records before '(' |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
mp,
I don't understand your post. Aneeta was the original poster, not you, so how can you know what Aneeta's answer to my question would be. All we know from what Aneeta said is that the number of records before the ( can vary. But we don't know if it's always the same number in both files, e.g. both have 3 records before ( or both have 4 records before (, etc. Anyway, Aneeta seems to have lost interest so we may never know. |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi,
Sorry for the late response.
The number of records before the '(' of file1 will not be equal to the number of records before the '(' of file2.
Sometimes no. of records in file1 before '(' will be greater than '(' in file2.Sometime no. of records in file2 before '(' will be lesser than '(' in file2.Also there will not be any similarity in the records before '(' in the 2 files.
For Eg:
File1:
LOG ON
REPLACE
RESUME
(
FIELD1 VARCHAR NULL
FIELD2 CHAR NULL
FIELD3 NUMERIC NULL
)
File2:
LOG OFF
DELETE
(
BREAK CHAR NULL
CREATE VARCHAR NULL
)
Outfile:
LOG ON
REPLACE
RESUME
(
BREAK CHAR NULL
CREATE VARCHAR NULL
)
Deeply regret for the inconvenience caused in clarifying the requirement.
Thanks for the response.Pls let me know if more explanation is required..Pls help me
Regards
Aneeta |
|
Back to top |
|
|
Alain Benveniste
New User
Joined: 14 Feb 2005 Posts: 88
|
|
|
|
aneeta,
Here is the solution you are looking for:
Code: |
//STEP0001 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
COPY FROM(IN) TO(OUTX) USING(ICE0)
/*
//IN DD *
LOG ON
REPLACE
RESUME
(
FIELD1 VARCHAR NULL
FIELD2 CHAR NULL
FIELD3 NUMERIC NULL
)
/*
// DD *
LOG OFF
DELETE
RESTART
(
BREAK CHAR NULL
CREATE VARCHAR NULL
)
/*
//OUTX DD SYSOUT=*
//ICE0CNTL DD *
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,5,ZD)),
IFTHEN=(WHEN=(1,1,CH,NE,C'('),
OVERLAY=(86:SEQNUM,5,ZD,
81:81,5,ZD,SUB,86,5,ZD,M11,LENGTH=5)),
IFTHEN=(WHEN=NONE,
OVERLAY=(81:SEQNUM,5,ZD))
OUTFIL FNAMES=OUTX,
OMIT=(81,5,CH;EQ,C'00001'),
OUTREC=(1,80)
|
Alain |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi Alain,
Can u pls explain the below statements for my understanding..
INREC IFTHEN=(WHEN=INIT,
OVERLAY=(81:SEQNUM,5,ZD)),
IFTHEN=(WHEN=(1,1,CH,NE,C'('),
OVERLAY=(86:SEQNUM,5,ZD,
81:81,5,ZD,SUB,86,5,ZD,M11,LENGTH=5)),
IFTHEN=(WHEN=NONE,
OVERLAY=(81:SEQNUM,5,ZD))
OUTFIL FNAMES=OUTX,
OMIT=(81,5,CH;EQ,C'00001'),
OUTREC=(1,80)
Thanks
Aneeta |
|
Back to top |
|
|
aneeta
New User
Joined: 08 Dec 2005 Posts: 48 Location: Chennai
|
|
|
|
Hi Alain,
The JCL is working pefectly fine.But I am facing an issue.The contents mentioned are in a file.If the JCL is coded as
//IN DD DSN=A.B.C,DISP=SHR
// DD DSN=D.E.F(A1),DISP=SHR
The contents of the 1st file is just copied into the output file. I have not changed anything in ur given JCL.
Pls correct me if I am wrong.
Thanks
Aneeta |
|
Back to top |
|
|
Alain Benveniste
New User
Joined: 14 Feb 2005 Posts: 88
|
|
|
|
aneeta,
The idea is to give a key value per group. The value is the same until a open parenthesis is met.
So:
LOG ON
REPLACE
RESUME
have key set to 0
(
FIELD1 VARCHAR NULL
FIELD2 CHAR NULL
FIELD3 NUMERIC NULL
)
LOG OFF
DELETE
RESTART
have key set to 1
(
BREAK CHAR NULL
CREATE VARCHAR NULL
)
have a key set to 2
Omiting recs with key value 1 give you the desired result.
The global logic is also explained here :
ibmmainframes.com/posting.php?mode=reply&t=18814&sid=1711736c024ce0f2819eaffbcbcdc746
and select Include or omit groups of records
you say
Quote: |
The JCL is working pefectly fine.But I am facing an issue.The contents mentioned are in a file.If the JCL is coded as
//IN DD DSN=A.B.C,DISP=SHR
// DD DSN=D.E.F(A1),DISP=SHR
The contents of the 1st file is just copied into the output file. I have not changed anything in ur given JCL.
|
if you post the sysout i could see why you don't have the result expected...
Alain |
|
Back to top |
|
|
|