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
 

 

SQZ With Sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Himanshu-kaushik

New User


Joined: 15 Mar 2007
Posts: 8
Location: delhi

PostPosted: Tue Nov 29, 2011 3:13 pm    Post subject: SQZ With Sort
Reply with quote

I have got input records as below

Code: Field1 – length 15 Field2 – Length 14
<-------------------> <--------------------->
Prasannaa S Vengatachalapathy
Sashi Kalasanna
Prince Yardley Kumar

Now I need the output as

Field1 – length 30
<--------------------------------------->
Prasannaa S,Vengatachalapathy
Sashi,Kalasanna
Prince Yardley,Kumar

I tried below solution but got a problem with Second field in the output file.
First two byte gets deleted.

OPTION COPY
INREC IFOUTLEN=30,
IFTHEN=(WHEN=INIT,
OVERLAY=(1:1,15,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',
LENGTH=17),
1:1,30,SQZ=(SHIFT=LEFT,MID=C'|',PAIR=QUOTE))),
IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',OUT=C''))

It shows the following output-

PRASANNAA S|NGATACHALAPA
SASHI|LASANNA
PRINCE YARDLEY|MAR

Please let me know where I am commiting mistake.
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7306

PostPosted: Tue Nov 29, 2011 3:49 pm    Post subject: Reply to: SQZ With Sort
Reply with quote

Please use the Code tags.

You are making your first field 17 bytes, overlaying what is there, so that blats two bytes of your second field.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Tue Nov 29, 2011 9:53 pm    Post subject:
Reply with quote

Himanshu-kaushik,
Without code tags, its hard to figure out the positions but you are potentially going to miss some of the trailing bytes.

From your example you show that field2 length is just 14 bytes but "Vengatachalapathy" exceeds that limit. How would you even get that value of 17 bytes in the 14 byte field?

Of course your final output in this case after SQZing is 30 bytes but to start with the field itself is more than 14 bytes.

Thanks,
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Nov 30, 2011 12:35 am    Post subject:
Reply with quote

Himanshu Kaushik,

You need to clarify what your input records look like and what you want the output records to look like.

What is the RECFM and LRECL of your input file? What is the expected RECFM and LRECL of your output file?

What is the starting position and length of each field in your input records?

What do you want for the separator in the output records - | or comma?
Back to top
View user's profile Send private message
pankaj.sethi12

New User


Joined: 29 Nov 2011
Posts: 1
Location: India

PostPosted: Thu Dec 01, 2011 9:31 am    Post subject: Requirement Explaination
Reply with quote

On Behalf of Himanshu Kaushiik, I will let you know the requirements.

MY Input File LRECL is 29 , Format is FB. I ant an output file with LRECL - 30 and RECFM -FB.
Input File has two fields - First Name and Second Name.
Fist Name is 15 Bytes and Second Name is 14 Bytes.
I want to come up with a Comma Seperated File haveing Comma in middle of both First NAme and Second Name. First Name can have more than two words seperated by a Space and I don't want to have comma in middle of these two words present in First name field. For Example-

Field1 – length 15 Field2 – Length 14
<-------------------> <--------------------->
Prasannaa S GUPTA
Sashi Kalasanna
Prince Yardley Kumar

Now I need the output as

Field1 – length 30
<--------------------------------------->
Prasannaa S,GUPTA
Sashi,Kalasanna
Prince Yardley,Kumar

I hope things would have become clear by above expaination. Please let me know in case you need any other Clarification.

Frank- Just wanted to let you know that you have already provided a solution for this problem at link - http://ibmmainframes.com/archive/o_t__t_43100__combining-two-fields-by-adding-delimiter-in-sort..html but unfortunately it does not work perfectly. It eats out first two bytes of Second Name as shown in the first message of this post(by Himanshu Kaushik).
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 578
Location: USA

PostPosted: Thu Dec 01, 2011 10:03 pm    Post subject:
Reply with quote

pankaj.sethi12,
Please use code tags. See if below works...

Code:
//STEP0001 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                     
PRASANNAA S    GUPTA                                                 
SASHI          KALASANNA                                             
PRINCE YARDLEY KUMAR                                                 
SQLCODE11111111AAAAAAAAAAAAAA                                       
S             QL                                                     
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                     
 OPTION COPY                                                         
 INREC IFOUTLEN=30,IFTHEN=(WHEN=INIT,                               
   BUILD=(01:01,15,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C',"',LENGTH=18),
             16,14,JFY=(SHIFT=LEFT))),                               
       IFTHEN=(WHEN=INIT,                                           
      OVERLAY=(01:01,32,SQZ=(SHIFT=LEFT,PAIR=QUOTE,LENGTH=30))),     
      IFTHEN=(WHEN=INIT,                                             
      FINDREP=(IN=C'"',OUT=C''))                                     
/*                                                                   

OUTPUT
Code:
PRASANNAA S,GUPTA             
SASHI,KALASANNA               
PRINCE YARDLEY,KUMAR           
SQLCODE11111111,AAAAAAAAAAAAAA
S             Q,L             

Thanks,
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm


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