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

Syncsort - to insert a line in a file at required place


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Tue Oct 11, 2011 4:56 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Oct 11, 2011 6:07 pm
Reply with quote

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
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Tue Oct 11, 2011 6:13 pm
Reply with quote

Hi Anuj,

sorry 'end of file' word is not present in the file. it means at the ending of the file.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Oct 11, 2011 6:20 pm
Reply with quote

any reason to post an exact duplicate of ?
ibmmainframeforum.com/viewtopic.php?f=28&t=6394
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Tue Oct 11, 2011 6:26 pm
Reply with quote

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
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Tue Oct 11, 2011 6:27 pm
Reply with quote

nothing both are two different sites, so I am trying here also.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Oct 11, 2011 6:30 pm
Reply with quote

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 icon_evil.gif
Back to top
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Tue Oct 11, 2011 6:50 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Oct 12, 2011 9:14 am
Reply with quote

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
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Wed Oct 12, 2011 11:58 am
Reply with quote

Thanks alot Gerry. it is working thank you very much.
Back to top
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Wed Oct 12, 2011 5:27 pm
Reply with quote

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
View user's profile Send private message
daveporcelan

Active Member


Joined: 01 Dec 2006
Posts: 792
Location: Pennsylvania

PostPosted: Wed Oct 12, 2011 6:17 pm
Reply with quote

Holy creeping requirement Batman!
Back to top
View user's profile Send private message
xknight

Active User


Joined: 22 Jan 2008
Posts: 117
Location: Liberty city

PostPosted: Wed Oct 12, 2011 6:24 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Oct 13, 2011 11:25 am
Reply with quote

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
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Fri Oct 14, 2011 12:07 pm
Reply with quote

Thank you it is working.
Back to top
View user's profile Send private message
vinodkumar_pallampati

New User


Joined: 29 Jun 2010
Posts: 20
Location: chennai

PostPosted: Tue Oct 18, 2011 12:51 pm
Reply with quote

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
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
Search our Forums:

Back to Top