View previous topic :: View next topic
|
Author |
Message |
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Hi,
I want to insert a comment line in a flat file using Syncsort.
requirement
**********
input file:
xxxxxx
1xxxxxx
xxxxx
1xxxx
xxxxx
EOF
output file:
xxxxxx
xx coment linexxxxx
1xxxxxx
xxxxx
xx coment linexxxxx
1xxxx
xxxxx
xx coment linexxxxx
EOF
in the input file whenever the first column is 1 above to that line I want to
insert a comment line and at the end of file.
Thanks,
Vinod. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Quote: |
in the input file whenever the first column is 1 above to that line I want to insert a comment line and at the end of file. |
What should be the starting and end position (length) for "the end of file"? |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Hi Anuj,
sorry 'end of file' word is not present in the file. it means at the ending of the file. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Okay, what is LRECL and RECFM of the file?
Also something does not match up here. Per the input and rules you give the output from this input:
Code: |
xxxxxx
1xxxxxx
xxxxx
1xxxx
xxxxx |
should be:
Code: |
**********
1xxxxxx
**********
1xxxx
xxxxx |
and not what you show. Also, I've assumed the "*"s in your called comment-line should be equal to the LRECL, which in my example is 10. |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
nothing both are two different sites, so I am trying here also. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10888 Location: italy
|
|
|
|
Quote: |
so I am trying here also. |
You should know that is improper to post the same question on different forums
even more improper when the two forums are related and the people providing answers are mostly the same
posting twice will not get You more answers or the same answers in a shorter time ...
it will just irritate people |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Hi Anuj,
LRECL =80 and RECFM = FB
the comment line length also 80. My comment line should not delete the
existing line only insert. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try this
Code: |
//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXXXX
1XXXXXX
XXXXX
1XXXX
XXXXX
// DD *
XX COMENT LINEXXXXX
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),
BUILD=(C'XX COMENT LINEXXXXX',/,
1,80))
END
/*
|
Gerry |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Thanks alot Gerry. it is working thank you very much. |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Hi Gerry,
is it possible to insert the comment line from the second time onwards.
I mean when it serach '1' at first time, comment line insertion is not needed from second time onwards it shoud be inserted. |
|
Back to top |
|
|
daveporcelan
Active Member
Joined: 01 Dec 2006 Posts: 792 Location: Pennsylvania
|
|
|
|
Holy creeping requirement Batman! |
|
Back to top |
|
|
xknight
Active User
Joined: 22 Jan 2008 Posts: 117 Location: Liberty city
|
|
|
|
Quote: |
is it possible to insert the comment line from the second time onwards.
I mean when it serach '1' at first time, comment line insertion is not needed from second time onwards it shoud be inserted. |
Yes possible, push the sequence no when you find the '1'
Code: |
PUSH=(81:SEQNUM,1,ZD) |
then use the
Code: |
OMIT COND=(1,1,ZD,EQ,C'1') |
Hope it helps |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try this
Code: |
//PS005 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
XXXXXX
1XXXXXX
XXXXX
1XXXX
XXXXX
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'1'),OVERLAY=(81:SEQNUM,8,ZD))
OUTFIL IFOUTLEN=80,
IFTHEN=(WHEN=(1,1,CH,EQ,C'1',&,81,08,ZD,GT,+1),
BUILD=(C'XX COMENT LINEXXXXX',/,
1,80)),
TRAILER1=(C'XX COMENT LINEXXXXX'),REMOVECC
END
/* |
Gerry |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Thank you it is working. |
|
Back to top |
|
|
vinodkumar_pallampati
New User
Joined: 29 Jun 2010 Posts: 20 Location: chennai
|
|
|
|
Hi Gerry,
small doubt suppose the input file LREC is not fixed to 80 and eachtime it is varying. so in this case is there any way to read the LREC of input file dynamically and passing to sort card.
Thanks,
Vinod. |
|
Back to top |
|
|
|