File - Remove Spaces



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

File - Remove Spaces

Postby mahesh100 » Mon Aug 31, 2009 6:15 pm

Hi,

I need to remove the padded spaces from one of the field.

File layout
two-char x(2)
three-char (3)
name x(35)
indicator 9(1)
indicator 9(1)

Input file



HEADER
IN,IND,INDIA                      ,1,0
GB,GBP,GREAT BRITAIN POUND        ,1,O
TRAILOR


(Remove all the extra spaces in the name field)
Output file:

HEADER
IN,IND,INDIA,1,0
GB,GBP,GREAT BRITIAN POUND,1,0
TRAILOR


I was thinking with Program but if can be done using DFSORT then it will be great.
Please let me know of any thoughts.
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File - Remove Spaces

Postby Frank Yaeger » Mon Aug 31, 2009 9:38 pm

You description of the layout doesn't match your example. Your layout describes fixed fields, but your example has comma delimited fields. Which is it?

Also, what is the RECFM and LRECL of the input file?

Is the name field the only one that can have embedded blanks?
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: File - Remove Spaces

Postby mahesh100 » Tue Sep 01, 2009 8:54 am

Frank,

Input file :
File layout
two-char x(2)
Filler value comma
three-char (3)
filler value comma
name x(40)
filler value comma
indicator 9(1)
filler value comma
indicator 9(1)


1) The file is delimited by comma.
2) Input file is fixed length and LRECL=51
3) Yes only Name field will have embedded spaces.

Thanks,
Mahe
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File - Remove Spaces

Postby dick scherrer » Tue Sep 01, 2009 10:13 am

Hello,

Do not post the same question in multiple parts of the forum. . .
ibm-cobol/topic2319.html#p9079

But still i am thinking on it ,how to use that ...
If any help on that will be great...


What is not clear? The input is a "not quite usable" delimited string (because of embedded spaces). If the string is unstrung into several variables, the meaningful length of each component can be calculated (field length minus trailing spaces), and then the values can be strung back together using reference modification, eliminating the unwanted trailing spaces.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 93 times

Re: File - Remove Spaces

Postby mahesh100 » Tue Sep 01, 2009 7:13 pm

Dick,

I wanted to use the ICETOOL or sort instead of program.
I am not sure why they want using sort, I guess it performance issue.

Thanks,
Mahesh
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File - Remove Spaces

Postby Frank Yaeger » Tue Sep 01, 2009 10:35 pm

Here's a D[size=150][/size]FSORT job that will do what you asked for:

//S1    EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=... input file (FB/51)
//SORTOUT DD DSN=... output file (FB/51)
//SYSIN    DD    *
  OPTION COPY
  INREC IFOUTLEN=51,
   IFTHEN=(WHEN=(3,1,CH,EQ,C','),
    BUILD=(1,7,8:8,40,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=42),
     50:48,4),HIT=NEXT),
   IFTHEN=(WHEN=(3,1,CH,EQ,C','),
     OVERLAY=(8:8,46,SQZ=(SHIFT=LEFT,PAIR=QUOTE)),HIT=NEXT),
   IFTHEN=(WHEN=(3,1,CH,EQ,C','),
     FINDREP=(IN=C'"',OUT=C''))
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: File - Remove Spaces

Postby mahesh100 » Wed Sep 02, 2009 9:01 am

Thanks Frank.
I will try this code.
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File - Remove Spaces

Postby mahesh100 » Wed Sep 02, 2009 8:47 pm

Thanks Frank... Its working Fine

But i did not get the logic of below line. Could you please let me know on this(What is the purpose of giving 50:48,4)

BUILD=(1,7,8:8,40,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'"',LENGTH=42),50:48,4),HIT=NEXT),

Thanks,
Mahesh
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: File - Remove Spaces

Postby Frank Yaeger » Thu Sep 03, 2009 12:43 am

We are adding quotes around the name which increases its length by 2. We need to shift the indicators after the name before we squeeze them together.

For example:

GB,GBP,GREAT BRITAIN POUND        ,1,O


would be justified to:

GB,GBP,"GREAT BRITAIN POUND"        ,1,O


then squeezed to:

GB,GBP,"GREAT BRITAIN POUND",1,O


Finally, the quotes are removed and we get:

GB,GBP,GREAT BRITAIN POUND,1,O
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post