|
View previous topic :: View next topic
|
| Author |
Message |
Himanshu-kaushik
New User
Joined: 15 Mar 2007 Posts: 8 Location: delhi
|
|
|
|
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 |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
 |
pankaj.sethi12
New User
Joined: 29 Nov 2011 Posts: 1 Location: India
|
|
|
|
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 |
|
 |
sqlcode1
Active Member
Joined: 08 Apr 2010 Posts: 577 Location: USA
|
|
|
|
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 |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|