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
 

 

Reformat a file using sort
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Thu Aug 16, 2012 2:50 pm    Post subject: Reformat a file using sort
Reply with quote

Hi,

I have a file with data as below
Code:

----+----1----+----2----+----3----+----4----+----5----+----6-
***************************** Top of Data *******************
abcdefg.txt                                                 
cd aaaaaa                                                   
cd bbbbbb                                                   
cd ccccccc                                                   
cd ddddddd                                                   
locsite pri=5 cy sec=1 cy u=testda rec=fb lr=1402 blocksi=0 
get                                                   +     
USER.NONX.USER9999.SAMPLE(+1)'                               
quit         


I need the output as below. The data in first line 'abcdefg.txt' needs to be moved after 'get' in 7th line.

Code:
----+----1----+----2----+----3----+----4----+----5----+----6-
***************************** Top of Data *******************
cd aaaaaa                                                   
cd bbbbbb                                                   
cd ccccccc                                                   
cd ddddddd                                                   
locsite pri=5 cy sec=1 cy u=testda rec=fb lr=1402 blocksi=0 
get abcdefg.txt                                       +     
USER.NONX.USER9999.SAMPLE(+1)'                               
quit                                                         
**************************** Bottom of Data *****************       


Please help to achieve this solution using Sort
Back to top
View user's profile Send private message

Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1713
Location: UK

PostPosted: Thu Aug 16, 2012 2:54 pm    Post subject:
Reply with quote

Well, you've already done it now so what is the problem?
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Thu Aug 16, 2012 3:03 pm    Post subject:
Reply with quote

Oh, no. I have just given how the output should look like.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Aug 16, 2012 3:24 pm    Post subject: Reply to: Reformat a file using sort
Reply with quote

With IFTHEN and WHEN=GROUP with RECORDS you can PUSH your filename. Include a SEQ.

with IFTHEN and WHEN=(logexp) you can identify the "get " and put the PUSHed item into the appropriate place.

Then on OUTFIL OMIT when the sequence is one to get rid of the now surplus record, and BUILD to get rid of the PUSHed data.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Aug 16, 2012 3:37 pm    Post subject:
Reply with quote

Bill,

Not sure how much effective this could be

If the file name abcdefg.txt going to be same always

Omit record with abcdefg.txt in first position

Change all get to get abcdefg.txt

Please correct me
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Thu Aug 16, 2012 3:48 pm    Post subject:
Reply with quote

Bill,

Could you please give a sample code with what you have suggested
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Aug 16, 2012 3:57 pm    Post subject:
Reply with quote

Quote:
Could you please give a sample code with what you have suggested


He did infact gave you the exact syntax

As your duty you could search the forum/Manual for samples and try learning them on how it works and implement it as your need

So in future you shall not depend on anyone for the similar requests
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 16, 2012 3:59 pm    Post subject:
Reply with quote

mksranjani wrote:
Bill,

Could you please give a sample code with what you have suggested


and the beat goes on!

ifpltaatrtimclid.
hey, this first letter stuff is great!
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Aug 16, 2012 6:42 pm    Post subject: Reply to: Reformat a file using sort
Reply with quote

Frank Yaeger wrote:
If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000080
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Thu Aug 16, 2012 6:46 pm    Post subject:
Reply with quote

Pandora-Box wrote:
Bill,

Not sure how much effective this could be

If the file name abcdefg.txt going to be same always

Omit record with abcdefg.txt in first position

Change all get to get abcdefg.txt

Please correct me


Yes, that would work.

You'd do it with the editor, and put it in a PDS/PDSE member... :-)

I was assuming, and I can easily be wrong, that the content of the first record is variable and a generalised solution was sought.

ywanicratmbwilfasstyp,

(yes dbz, it is fun) if you can't be bothered to look at the manuals, at least search the forum for the key words I gave you (they were real words, not abbreviations of expressions) and you should be able to get it.
Back to top
View user's profile Send private message
knickraj
Warnings : 1

New User


Joined: 11 Jun 2007
Posts: 50
Location: Euro

PostPosted: Thu Aug 16, 2012 8:16 pm    Post subject:
Reply with quote

sample code...

Code:
//STEP EXEC SORT                                                 
//SYSOUT   DD SYSOUT=*                                           
//SORTIN  DD *                                                   
ABCDEFG.TXT                                                       
CD AAAAAA                                                         
CD BBBBBB                                                         
CD CCCCCCC                                                       
CD DDDDDDD                                                       
LOCSITE PRI=5 CY SEC=1 CY U=TESTDA REC=FB LR=1402 BLOCKSI=0       
GET                                                   +           
USER.NONX.USER9999.SAMPLE(+1)'                                   
QUIT                                                             
//SORTOUT  DD SYSOUT=*                                           
//SYSIN  DD *                                                     
 OPTION COPY                                                     
 INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'GET'),OVERLAY=(5:C'ABCDEFG.TXT'))
 OMIT COND=(1,11,CH,EQ,C'ABCDEFG.TXT')   



Code:
//STEP EXEC SORT                                           
//SYSOUT   DD SYSOUT=*                                     
//SORTIN  DD *                                             
ABCDEFG.TXT                                                 
CD AAAAAA                                                   
CD BBBBBB                                                   
CD CCCCCCC                                                 
CD DDDDDDD                                                 
LOCSITE PRI=5 CY SEC=1 CY U=TESTDA REC=FB LR=1402 BLOCKSI=0
GET                                                   +     
USER.NONX.USER9999.SAMPLE(+1)'                             
QUIT                                                       
//SORTOUT  DD SYSOUT=*                                     
//SYSIN  DD *                                               
 OPTION COPY                                               
 INREC IFTHEN=(WHEN=GROUP,                                 
   BEGIN=(1,11,CH,EQ,C'ABCDEFG.TXT'),                       
   END=(1,3,CH,EQ,C'GET'),                                 
   PUSH=(81:1,11)),                                         
 IFTHEN=(WHEN=(1,3,CH,EQ,C'GET'),OVERLAY=(5:81,11))         
 OUTFIL OMIT=(1,11,CH,EQ,C'ABCDEFG.TXT'),BUILD=(1,80)


P.S, I have used CAPS ON.
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Thu Aug 16, 2012 9:39 pm    Post subject: Reply to: Reformat a file using sort
Reply with quote

Hi,

I have coded the below sort. But it is showing error. Can someone please help,

Code:
 SORT FIELDS=COPY                                                       
 INREC IFTHEN=(WHEN=GROUP,RECORDS=9,PUSH=(81:ID=1,83:SEQ=1),           
       IFTHEN=(WHEN=(1,3,CH,EQ,'get',AND,81,1,ZD,EQ,1),PUSH=(81:1,32)) 
 OUTFIL OMIT=(SEQ=1),BUILD=(1,80)                                       
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Aug 16, 2012 9:42 pm    Post subject:
Reply with quote

Hello,

Is there some reason you have not posetd the error(s) icon_sad.gif

You need to post all of the diagnostic information generated including the complete message id(s).
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Thu Aug 16, 2012 9:46 pm    Post subject:
Reply with quote

Sorry, please find below the error message

Code:
SYSIN :                                                                 
 SORT FIELDS=COPY                                                       
 INREC IFTHEN=(WHEN=GROUP,RECORDS=9,PUSH=(81:ID=1))                     
 INREC IFTHEN=(WHEN=(1,3,CH,EQ,'get',AND,81,1,ZD,EQ,1),PUSH=(81:1,32)) 
 *                                                                     
 OUTFIL OMIT=(SEQ=1),BUILD=(1,80)                                       
              *                                                         
WER269A  INREC STATEMENT   : DUPLICATE STATEMENT FOUND                 
WER268A  OUTFIL STATEMENT  : SYNTAX ERROR                               
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000                           
WER449I  SYNCSORT GLOBAL DSM SUBSYSTEM ACTIVE   
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10202
Location: italy

PostPosted: Thu Aug 16, 2012 9:51 pm    Post subject: Reply to: Reformat a file using sort
Reply with quote

the WER.... messages indicate that You are using SYNCSORT, not DFSORT

topic moved where it belongs
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Thu Aug 16, 2012 9:53 pm    Post subject:
Reply with quote

Knick,

'ABCDEFG.txt' is a variable. It is not the same always.
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Aug 16, 2012 10:00 pm    Post subject:
Reply with quote

Also If your

abcdefg.txt file name is not going to change

The other solution by Knickraj should work for Syncsort
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Aug 16, 2012 10:04 pm    Post subject:
Reply with quote

So you can make use of SYMNAMES and reformat using Knick's solution
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1738
Location: Bloomington, IL

PostPosted: Thu Aug 16, 2012 10:07 pm    Post subject: Re: Reply to: Reformat a file using sort
Reply with quote

mksranjani wrote:
Hi,

I have coded the below sort. But it is showing error. Can someone please help,

Code:
 SORT FIELDS=COPY                                                       
 INREC IFTHEN=(WHEN=GROUP,RECORDS=9,PUSH=(81:ID=1,83:SEQ=1),           
       IFTHEN=(WHEN=(1,3,CH,EQ,'get',AND,81,1,ZD,EQ,1),PUSH=(81:1,32)) 
 OUTFIL OMIT=(SEQ=1),BUILD=(1,80)                                       

which is not the same as
Quote:
Code:
 SORT FIELDS=COPY                                                       
 INREC IFTHEN=(WHEN=GROUP,RECORDS=9,PUSH=(81:ID=1))                     
 INREC IFTHEN=(WHEN=(1,3,CH,EQ,'get',AND,81,1,ZD,EQ,1),PUSH=(81:1,32)) 
 OUTFIL OMIT=(SEQ=1),BUILD=(1,80)     

How can you expect meaningful help if you do not tell us what you have actually done?
Back to top
View user's profile Send private message
Pandora-Box

Moderator


Joined: 07 Sep 2006
Posts: 1529
Location: Andromeda Galaxy

PostPosted: Thu Aug 16, 2012 10:12 pm    Post subject:
Reply with quote

Also 'get' should be C'get'

I find it wrong atleast
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
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 Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 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