View previous topic :: View next topic
Author
Message
Deepa.m New User Joined: 28 Apr 2005Posts: 99
All,
I am looking for a solution where I need to read the i/p file and write the o/p records as per below logic
when code='BOC' and Ind =(R or C) then write to file1 and file2
when IND=R and status code= O write to file1
when IND=C and status code = O write to File 2
Can i write the selected records to 2 files at the same time?
Thanks,
Deepa
Back to top
guptae Moderator Joined: 14 Oct 2005Posts: 1208 Location: Bangalore,India
Hello Deepa,
Please provide us sample input , output as well Sort Utility running on ur system.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Deepa,
Please show an example of the records in your input file (relevant fields only) and what you expect for output. Explain the "rules" for getting from input to output. Give the starting position, length and format of each relevant field. Give the RECFM and LRECL of the input file.
Quote:
Can i write the selected records to 2 files at the same time?
Yes, with DFSORT OUTFIL statements.
Back to top
Deepa.m New User Joined: 28 Apr 2005Posts: 99
Hi all
My apologies. Here are the details
LRECL = 61
Code:
field name position length format
CODE 12 3 ch
IND 14 1 ch
STATUS 15 1 ch
IF CODE='BOC' and IND =(R or C) then write to file1 and file2
else
if IND=R and STATUS= O write to file1
else
if IND=C and STATUS = O write to File 2
example i/p
48294843490BOC 0R 0O 00000000000
48294843490[b]CAD 0R 0O 00000000000
48294843490[b]COL 0C 0O 00000000000
48294843490[b]CAM 0C 0O 00000000000
48294843490[b]CAM 0C 0P 00000000000
file 1
48294843490[b]BOC 0R 0O 00000000000
48294843490[b]CAD 0R 0O 00000000000
file 2
48294843490BOC 0R 0O 00000000000
48294843490[b]COL 0C 0O 00000000000
48294843490[b]CAM 0C 0O 00000000000
Thanks,
Deepa.
Back to top
Deepa.m New User Joined: 28 Apr 2005Posts: 99
example i/p
48294843490BOC0R0O00000000000
48294843490CAD0R0O00000000000
48294843490COL0C0O00000000000
48294843490CAM0C0O00000000000
48294843490CAM0C0P00000000000
file 1
48294843490BOC0R0O00000000000
48294843490CAD0R0O00000000000
file 2
48294843490BOC0R0O00000000000
48294843490COL0C0O00000000000
48294843490CAM0C0O00000000000
Back to top
sqlcode1 Active Member Joined: 08 Apr 2010Posts: 577 Location: USA
Deepa,
From what you have shown in the sample input seems like your Fields are overlapping.
1) code field ends at 14th position but then you show your indicator at 14th position as well.
2) You mentioned status is at 15th position as compared to 16th position shown by you in the sample data.
Thanks,
Back to top
smijoss Active User Joined: 30 Aug 2007Posts: 114 Location: pune
with hint Frank gave a good 10 minutes read could have solved your problem
Code:
OUTFIL FNAMES=FILE1,
INCLUDE=((12,3,CH,C'BOC',AND,16,1,SS,C'RC'),OR,
(16,1,CH,EQ,C'R',AND,18,1,CH,EQ,C'O'))
OUTFIL FNAMES=FILE2,
INCLUDE=((12,3,CH,C'BOC',AND,16,1,SS,C'RC'),OR,
(16,1,CH,EQ,C'C',AND,18,1,CH,EQ,C'O'))
sqlcode1 - good catch
Back to top
Deepa.m New User Joined: 28 Apr 2005Posts: 99
I was specifically looking if there is any way to write the output records to 2 files when it matches instead of repeating the condition check twice.
OUTFIL FNAMES=FILE1,
INCLUDE=((12,3,CH,C'BOC',AND,16,1,SS,C'RC' ),OR,
(16,1,CH,EQ,C'R',AND,18,1,CH,EQ,C'O'))
OUTFIL FNAMES=FILE2,
INCLUDE=((12,3,CH,C'BOC',AND,16,1,SS,C'RC' ),OR,
(16,1,CH,EQ,C'C',AND,18,1,CH,EQ,C'O'))
Please ignore my example if that is misleading.
something like OUTFIL FNAMES=FILE1,FILE2,INCLUDE=((12,3,CH,C'BOC',AND,16,1,SS,C'RC' )
Thanks,
Deepa.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Back to top
Deepa.m New User Joined: 28 Apr 2005Posts: 99
Thank u
I will do a initial research before raising my question
Thanks to all for your patience
Back to top
Please enable JavaScript!