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
 

 

Removing Spaces and Inserting delimiter

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

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed Aug 31, 2011 3:06 am    Post subject: Removing Spaces and Inserting delimiter
Reply with quote

Hi,

I have to remove trailing spaces for a particular field and but the issue is this field can have spaces in between. I am using

Code:

1,44,SQZ=(SHIFT=LEFT),C',',45,8,SQZ=(SHIFT=LEFT)


But the above one is removing spaces which are in between the value.

My Input looks like (record length=80,Record Format=FB)

Code:

Field1                                        Field2 
(1-44)                                        (45-52)
ABC DEF GHI & JKML                          135 2432


Expected Output

Code:

ABC DEF GHI & JKML,135 2432


But I am getting as below.
Code:

ABCDEFGHI&JKML,1352432


How can we handle spaces which are in between of the field? Appreciate your help.
Back to top
View user's profile Send private message

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Aug 31, 2011 3:14 am    Post subject: Reply to: Removing Spaces and Inserting delimiter
Reply with quote

ksk,

Assuming there is a single space between words you can use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD *                                             
ABC DEF GHI & JKML                          135 2432       
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  INREC BUILD=(1,44,C',',45,8,53,27)                       
  OUTREC FINDREP=(INOUT=(C'  ',C'',C' ,',C',',C', ',C',')) 
//*
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Wed Aug 31, 2011 3:33 am    Post subject: Reply to: Removing Spaces and Inserting delimiter
Reply with quote

Thanks for the immediate reply.

Can you please explain what the below code does?

Code:

INOUT=(C'  ',C'',C' ,',C',',C', ',C',')


Please note that one field can have any number of single spaces in between or cannot have even a single space in between.
For ex,

Code:

A B CDE FGHI KDJFJ D S
ABCDEFGRHYSJFDJFKJFK
SFDHDSFSD ASDSD GFG


In the above I/P, respective field of the first record has 6 single spaces in between and 2nd record does not have any spaces and the third has 2 spaces so on...
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Aug 31, 2011 4:35 am    Post subject: Reply to: Removing Spaces and Inserting delimiter
Reply with quote

ksk wrote:
Can you please explain what the below code does?


The First C'bb' is looking for 2 adjacent spaces(b= blank) and eliminating them. so if there are even number of space at the end they would get all eliminated and the other conditions are checking for odd number of spaces and starting spaces for field 2.

You are fine as long as your field 1 has single spaced words. It doesn't matter how many words you have.

however if your data has
Code:

ABC  FH  <== 2 adjacent spaces between ABC and FH


Your output would be

Code:

ABCFH


So as long as you maintain single spacing between words you are fine.

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
Frank Yaeger

DFSORT Moderator


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

PostPosted: Wed Aug 31, 2011 5:25 am    Post subject:
Reply with quote

ksk,

Here's another way to do it with DFSORT which will preserve any number of spaces between the words.

Code:

  OPTION COPY                                                       
  INREC IFTHEN=(WHEN=INIT,                                           
   BUILD=(1,44,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'",',LENGTH=47),     
     45,8,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=10))),         
   IFTHEN=(WHEN=INIT,BUILD=(1,57,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),     
   IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',OUT=C''))                     


For example, if the input is:

Code:

ABC DEF GHI & JKML                          135 2432 
ABC DEF GHI & JKML    QR                    135 2432 
ABC DEF GHI & JKML           XYZ      AB    135  432 


The output will be:

Code:

ABC DEF GHI & JKML,135 2432                           
ABC DEF GHI & JKML    QR,135 2432                     
ABC DEF GHI & JKML           XYZ      AB,135  432     
Back to top
View user's profile Send private message
ksk

Active User


Joined: 08 Jun 2006
Posts: 356
Location: New York

PostPosted: Thu Sep 01, 2011 2:18 am    Post subject: Reply to: Removing Spaces and Inserting delimiter
Reply with quote

Thanks Kolusu and Frank. Worked perfectly for my requirement.
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 Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am
No new posts Removing the MODETAB field in a VTAM ... rcwing All Other Mainframe Topics 1 Fri Feb 19, 2016 7:11 pm
No new posts Remove intermediate spaces Pallavi Vishwanath SYNCSORT 1 Fri Jan 15, 2016 2:45 am


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