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

Reformat a file using sort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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: 2455
Location: Hampshire, UK

PostPosted: Thu Aug 16, 2012 2:54 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 16, 2012 3:24 pm
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

Global Moderator


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

PostPosted: Thu Aug 16, 2012 3:37 pm
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
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

Global Moderator


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

PostPosted: Thu Aug 16, 2012 3:57 pm
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
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 16, 2012 6:42 pm
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:

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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 16, 2012 6:46 pm
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
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
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

Moderator Emeritus


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

PostPosted: Thu Aug 16, 2012 9:42 pm
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Aug 16, 2012 9:51 pm
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
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

Global Moderator


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

PostPosted: Thu Aug 16, 2012 10:00 pm
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

Global Moderator


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

PostPosted: Thu Aug 16, 2012 10:04 pm
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: 1788
Location: Bloomington, IL

PostPosted: Thu Aug 16, 2012 10:07 pm
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

Global Moderator


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

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

Also 'get' should be C'get'

I find it wrong atleast
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 16, 2012 10:41 pm
Reply with quote

Make the change pointed out by Pandora-Box. I would always include at least one space, so that I know I've got "get" not something which begins with "get".

Also look to your OMIT. You can't do SEQ like that. You need to define where the GROUP PUSHed the SEQ and then test that for one.

If this doesn't get it, post the whole sysout.
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 11:24 pm
Reply with quote

try this..

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 DSN=&&T,DISP=(,PASS),SPACE=(TRK,(1,0),RLSE)   
//SYSIN  DD *                                               
 OPTION COPY                                               
 OUTFIL REMOVECC,NODETAIL,BUILD=(80X),                     
   HEADER1=('FILE,C''',1,11,'''')                           
//STEP EXEC SORT                                           
//SYSOUT   DD SYSOUT=*                                     
//SYMNAMES DD DSN=&&T,DISP=SHR                             
//SORTOUT  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                                                       
//SYSIN  DD *                                               
 OPTION COPY                                               
 OMIT COND=(1,11,CH,EQ,FILE)                               
 INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'GET'),OVERLAY=(5:FILE))
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Aug 17, 2012 12:01 am
Reply with quote

Hello,

Quote:
OUTFIL OMIT=(SEQ=1),BUILD=(1,80)
Suggest you try removing
OMIT=(SEQ=1), and try again.
Back to top
View user's profile Send private message
mksranjani

New User


Joined: 03 Feb 2010
Posts: 29
Location: Chennai

PostPosted: Fri Aug 17, 2012 8:18 am
Reply with quote

I have tried removing OMIT. Below is the error i got
Code:

 SYSIN :                                                                       
 SORT FIELDS=COPY                                                             
 INREC IFTHEN=(WHEN=GROUP,RECORDS=9,PUSH=(81:ID=1)),                           
       IFTHEN=(WHEN=(1,3,CH,EQ,C'get',AND,81,1,ZD,EQ,1),PUSH=(81:1,32))       
                                                        *                     
 OUTFIL BUILD=(1,80)                                                           
WER268A  INREC 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
dick scherrer

Moderator Emeritus


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

PostPosted: Fri Aug 17, 2012 8:34 am
Reply with quote

Hello,

What is the lrecl of the files?
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
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