Remove trailing spaces and replace character



Support for NetApp SyncSort for z/OS, Visual SyncSort, SYNCINIT, SYNCLIST and SYNCTOOL

Remove trailing spaces and replace character

Postby danny_ce16 » Tue Nov 15, 2011 10:43 am

Hi,

i have a VB file of rec len 80 with the following recs.

C;0088999;TEST NAME NAME1 ;1485/1111111111111
D;1122333;TESTNAME NAME23 NAME7 ;2596/3333333333333
E;5555444;TESTTEST NAME NAME4 ;3912/5555555555555

i need to replace the first character with a number (C to 1, D to 2 E to 3) and remove the trailing spaces that appears after the name, giving the output as below

1;007788999;TEST NAME NAME1;14785/111111111111111
2;111222333;TESTNAME NAME23 NAME7;25896/333333333333333
3;321654987;TESTTEST NAME NAME4;36912/555555555555555

Thanks in advance.
danny_ce16
 
Posts: 15
Joined: Mon Oct 24, 2011 6:14 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Remove trailing spaces and replace character

Postby danny_ce16 » Tue Nov 15, 2011 10:59 am

for clear data, from

C;007788999;TEST NAME NAME1                          ;14785/111111111111111
D;111222333;TESTNAME NAME23 NAME7                    ;25896/333333333333333
E;321654987;TESTTEST NAME NAME4                      ;36912/555555555555555


to

1;007788999;TEST NAME NAME1;14785/111111111111111
2;111222333;TESTNAME NAME23 NAME7;25896/333333333333333
3;321654987;TESTTEST NAME NAME4;36912/555555555555555
danny_ce16
 
Posts: 15
Joined: Mon Oct 24, 2011 6:14 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Remove trailing spaces and replace character

Postby BillyBoyo » Tue Nov 15, 2011 1:13 pm

Thanks for taking the time to improve the readability.

For the replacement, have you looked at IFTHEN with WHEN= and then an OVERLAY?

For removing the trailing blanks, have a look at SQZ.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Remove trailing spaces and replace character

Postby danny_ce16 » Tue Nov 15, 2011 5:52 pm

yes Bill, i first converted the file to FB and then tried to squeeze.

INREC OVERLAY=(1,80,SQZ=(SHIFT=LEFT,MID=C' '))

but im getting a single space at the end of name fields displayed.. the names shouldnt have any trailing spaces
danny_ce16
 
Posts: 15
Joined: Mon Oct 24, 2011 6:14 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Remove trailing spaces and replace character

Postby BillyBoyo » Tue Nov 15, 2011 6:05 pm

Have a check in the DFSORT manual waht the MID=C' ' is doing. That is where your extra space is coming from.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Remove trailing spaces and replace character

Postby danny_ce16 » Tue Nov 15, 2011 6:25 pm

without MID=C' ', it would remove all the spaces including the one in between the first name,middle name and last name right?
danny_ce16
 
Posts: 15
Joined: Mon Oct 24, 2011 6:14 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Remove trailing spaces and replace character

Postby BillyBoyo » Tue Nov 15, 2011 8:53 pm

But you are not doing it to a field, there is another field after it. It is treating your whole 80 characters and will put a blank everywhere between first and last non-blank when it removes the spaces.

So, yes, your MID is preserving spaces between name elements, but inserting a space after the last name element because it is followed by something else.

I guess you want a way around it as well?

Maybe if you BUILD the output record so that you just do the SQZ on any fields which need the spaces dropped? Keeping the MID as you have it, but at field level.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Remove trailing spaces and replace character

Postby Frank Yaeger » Wed Nov 16, 2011 12:35 am

Danny,

Here's a DFSORT job that will do what you asked for:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (VB/80)
//SORTOUT DD DSN=...  output file (VB/80)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=80,
   IFTHEN=(WHEN=INIT,
    BUILD=(1,4,5,1,CHANGE=(1,C'C',C'1',C'D',C'2',C'E',C'3'),
      6,11,17,41,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'";',LENGTH=44),
      59,22)),
   IFTHEN=(WHEN=INIT,
     BUILD=(1,4,5,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),
   IFTHEN=(WHEN=INIT,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: Remove trailing spaces and replace character

Postby danny_ce16 » Wed Nov 16, 2011 11:43 am

its failing for me

SYSIN :                                                             
    OPTION COPY                                                     
    INREC IFOUTLEN=80,                                             
     IFTHEN=(WHEN=INIT,                                             
      BUILD=(1,4,5,1,CHANGE=(1,C'P',C'1',C'B',C'2',C' ',C'3'),     
        6,11,17,41,JFY=(SHIFT=LEFT,LEAD=C'"',TRAIL=C'";',LENGTH=44),
        59,22)),                                                   
     IFTHEN=(WHEN=INIT,                                             
       BUILD=(1,4,5,80,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),               
     IFTHEN=(WHEN=INIT,FINDREP=(IN=C'"',OUT=C''))                   
                       *                                           
WER268A  INREC STATEMENT   : SYNTAX ERROR                           
WER211B  SYNCSMF  CALLED BY SYNCSORT; RC=0000


am i missing something here..?
danny_ce16
 
Posts: 15
Joined: Mon Oct 24, 2011 6:14 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Remove trailing spaces and replace character

Postby NicC » Wed Nov 16, 2011 11:58 am

Yes - you are missing the fact that you are using SYNCSORT and that this is the DFSORT section of the forum - not the SYNCSORT section. As the 2 products are not the same (although similar) control cards for one will not necessarily work for the other.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Next

Return to Syncsort/Synctool

 


  • Related topics
    Replies
    Views
    Last post