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

SQZ With Sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Tue Nov 29, 2011 3:49 pm
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: 577
Location: USA

PostPosted: Tue Nov 29, 2011 9:53 pm
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 Developer


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

PostPosted: Wed Nov 30, 2011 12:35 am
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
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 - 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: 577
Location: USA

PostPosted: Thu Dec 01, 2011 10:03 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top