Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

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

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Syncsort - to insert a line in a file at required place
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

Senior Member


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

PostPosted: Tue Oct 11, 2011 6:07 pm    Post subject:
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    Post subject: Reply to: Syncsort - to insert a line in a file at required
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Oct 11, 2011 6:20 pm    Post subject: Reply to: Syncsort - to insert a line in a file at required
Reply with quote

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

Senior Member


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

PostPosted: Tue Oct 11, 2011 6:26 pm    Post subject:
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    Post subject: Reply to: Syncsort - to insert a line in a file at required
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Oct 11, 2011 6:30 pm    Post subject: Reply to: Syncsort - to insert a line in a file at required
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    Post subject: Reply to: Syncsort - to insert a line in a file at required
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: 1703
Location: Australia

PostPosted: Wed Oct 12, 2011 9:14 am    Post subject:
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    Post subject: Reply to: Syncsort - to insert a line in a file at required
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    Post subject: Reply to: Syncsort - to insert a line in a file at required
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: 645
Location: Pennsylvania

PostPosted: Wed Oct 12, 2011 6:17 pm    Post subject:
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    Post subject:
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: 1703
Location: Australia

PostPosted: Thu Oct 13, 2011 11:25 am    Post subject:
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    Post subject: Reply to: Syncsort - to insert a line in a file at required
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts syncsort: copy lines after the keyword shreya19 SYNCSORT 1 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us