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

[Solved]Removing certain character from each record.


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pushpagiri

New User


Joined: 07 Jul 2005
Posts: 51

PostPosted: Tue Dec 06, 2005 7:48 pm
Reply with quote

Hi,

This is my problem :

Expanation:
I want to remove the character '$' from each line of file1.
But while doing so there should be any space introduced( instead of '$')

file1:

Code:

aaaa  bbbbb$$$$$$xxxxx   xx$$$$
bbb  bbbb$$$$$$$$$ccccc    cccccc$$


Outfile:

Code:

aaaa  bbbbbxxxxx   xx
bbb  bbbbccccc    cccccc


Please guide me to some solution.
Thanks in advance.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Dec 06, 2005 8:14 pm
Reply with quote

Give this command at command line in EDIT MODE....C $ '' ALL ...

Regards,

Priyesh.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Dec 06, 2005 8:16 pm
Reply with quote

The command above will delete all the occurrences of $ from the file....

If you want to insert an SPACE in place of $... give this..C $ ' ' ALL..

Regards,

Priyesh.
Back to top
View user's profile Send private message
pushpagiri

New User


Joined: 07 Jul 2005
Posts: 51

PostPosted: Tue Dec 06, 2005 8:34 pm
Reply with quote

Hi Priyesh,

Is it possible through any JCL.Because this is a step required in a process
which should be done through JCL.

Also I want the output in a dataset.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Tue Dec 06, 2005 8:50 pm
Reply with quote

Thru INREC statement with CHANGE option it should be possible to achieve what you want in DFSORT's way.

Is $ occurring at any specific location...else it would be bit difficult checking each & every character in the file...Frank will be knowing the better way...

Well, What is REC LENGTH & format of your Input file...

Regards,

Priyesh.
Back to top
View user's profile Send private message
pushpagiri

New User


Joined: 07 Jul 2005
Posts: 51

PostPosted: Tue Dec 06, 2005 8:57 pm
Reply with quote

hi,

It is FB of length 160.
Yes priyesh.The character '$' can occur at any position in the input file.
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: Tue Dec 06, 2005 9:01 pm
Reply with quote

Push,

DFSORT's TRAN=ALTSEQ feature can be used to replace each $ with a blank. But I believe you want to actually remove the $ characters and shift the other characters to the left - is that correct?
Back to top
View user's profile Send private message
pushpagiri

New User


Joined: 07 Jul 2005
Posts: 51

PostPosted: Wed Dec 07, 2005 10:23 am
Reply with quote

Frank,
Sorry for the small mistake in my post:
{Expanation:
I want to remove the character '$' from each line of file1.
But while doing so there should be any space introduced( instead of '$')
}


Correction:
But while doing so there should not be any space introduced( instead of '$')

Yes Frank.I want to remove $ and shift other characters to left.
But with ALTSEQ the characters will not be shifted and spaces will be
inserted.

Is there any way to implement the method of Priyesh though any JCL.
(CHANGE ALL '$' '').Can this be done through any of these -DFSORT,ICEMAN,ICETOOL?
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Dec 07, 2005 3:22 pm
Reply with quote

Hi Push,

To solve your problem by JCL way, here is another solution.

REXX SCRIPT....
Code:
ADDRESS TSO                                         
'PROFILE NOPREFIX'                                   
SAY '- BEGIN ---------------------------------'     
"EXECIO * DISKR FILELIST (STEM FILELIST. FINIS"     
DO ILIST = 1 TO FILELIST.0                           
I = 0                                               
TABTMP. = ''                                         
TABTMP.0 = 0                                         
FILELIST.ILIST = STRIP(FILELIST.ILIST,T)             
SAY ' FILE IN PROGRESS: ' FILELIST.ILIST             
"ALLOC DA("FILELIST.ILIST") F(FILEIN) SHR"           
"EXECIO * DISKR FILEIN(STEM TABTMP. FINIS"           
"FREE F(FILEIN)"                                     
"ALLOC DA("FILELIST.ILIST") F(FILEOUT) OLD"         
/* DEFINE STRING TO BE CHANGED */                   
CHANGED = 0                                         
PAR1 = '$'                                   
PAR2 = ''                                 
CALL CHANGE                                                 
"EXECIO * DISKW FILEOUT(STEM TABTMP. FINIS"                 
"FREE F(FILEOUT)"                                           
END                                                         
SAY '- END -----------------------------------'             
EXIT RC                                                     
CHANGE:                                                     
DO I = 1 TO TABTMP.0                                         
IF INDEX(TABTMP.I,PAR1) > 0 THEN DO                         
CHANGED = CHANGED + 1                                       
STRAPP = DELSTR(TABTMP.I,INDEX(TABTMP.I,PAR1),LENGTH(PAR1)) 
TABTMP.I = INSERT(PAR2,STRAPP,INDEX(TABTMP.I,PAR1)-1)       
END                                                         
END                                                         
RETURN             


Job to run this script
Code:
//STEPREXX EXEC PGM=IKJEFT01,PARM='MEMBERNAME' 
//SYSEXEC DD DISP=SHR,DSN=PDS.HAVING.MEMBER.OF.REXX,
//SYSTSPRT DD SYSOUT=*                       
//SYSTSIN DD DUMMY                           
//FILELIST DD *           
INPUT.NAME.DSN1
//*


You need to run this job step in order to remove $ from the file.
Put this REXX Script in a PDS. member name to be specified in PARM parameter.

Check & let us know the results.

Regards,

Priyesh.
Back to top
View user's profile Send private message
pushpagiri

New User


Joined: 07 Jul 2005
Posts: 51

PostPosted: Wed Dec 07, 2005 6:54 pm
Reply with quote

Hi priyesh,

Actually I don't have much knowledge in REXX.Am a <beginner in that.
I tested your code.But the output remains the same.
I don't know where it got problem.
Am trying to undersatnd your code.

Code:
STRAPP = DELSTR(TABTMP.I,INDEX(TABTMP.I,PAR1),LENGTH(PAR1)) 
TABTMP.I = INSERT(PAR2,STRAPP,INDEX(TABTMP.I,PAR1)-1)



Is there any need to insert PAR2 after deleting the PAR1?
Am not sure about it.

(but thankz for your great effort)
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Dec 07, 2005 7:02 pm
Reply with quote

Hi Push,

Actually this code is supposed to change PAR1 to PAR2...
For which I kept PAR1='$' & PAR2='' (means nothing for PAR2).

So no need to insert PAR2 seperately...

Quote:
(but thankz for your great effort)

I forgot to mentione earlier... this to be lead to MGIndaco, who earlier provided me this REXX Code for one of my problem.
I been the communicator in this case.

Regards,

Priyesh.
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Dec 07, 2005 7:33 pm
Reply with quote

Push,

I just now tested & it is working fine for me.

Regards,

Priyesh.
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 Dec 07, 2005 9:32 pm
Reply with quote

Quote:
Can this be done through any of these -DFSORT,ICEMAN,ICETOOL?


Sort products do not have any built-in features to do this kind of thing.

FYI, PGM=ICEMAN is just a way to invoke your sort product (e.g. DFSORT).
Back to top
View user's profile Send private message
pushpagiri

New User


Joined: 07 Jul 2005
Posts: 51

PostPosted: Thu Dec 08, 2005 10:22 am
Reply with quote

Hi Priyesh,

I have solved it finally( but not without your help)
The REXX code changed the first occurance of '$' only.
So the following IF should be changed to DO WHILE.

Code:
IF INDEX(TABTMP.I,PAR1) > 0 THEN DO                         
CHANGED = CHANGED + 1                                       
STRAPP = DELSTR(TABTMP.I,INDEX(TABTMP.I,PAR1),LENGTH(PAR1)) 
TABTMP.I = INSERT(PAR2,STRAPP,INDEX(TABTMP.I,PAR1)-1)       
END


Code:
DO WHILE INDEX(TABTMP.I,PAR1) > 0                           
CHANGED = CHANGED + 1                                       
STRAPP = DELSTR(TABTMP.I,INDEX(TABTMP.I,PAR1),LENGTH(PAR1)) 
TABTMP.I = INSERT(PAR2,STRAPP,INDEX(TABTMP.I,PAR1)-1)       
END


Thank you very much Priyesh(and MGIndaco too).Without your help,I couldnot have solved this problem.

Thanks and Regards,
Push
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: Fri May 12, 2006 3:27 am
Reply with quote

With z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006), we can now do this kind of thing with DFSORT. This particular case is a bit tricky because it has '$' characters that should be removed and multiple blanks that should not be removed. But here's a DFSORT job that will do it for the RECFM=FB/LRECL=160 input data set:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT   DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/160)
//SORTOUT DD DSN=...  output file (FB/160)
//SYSIN DD    *
  OPTION COPY
  ALTSEQ CODE=(40FF,FF40)
* Replace blanks with X'FF's to protect them.
  INREC IFTHEN=(WHEN=INIT,
          BUILD=(1,161,TRAN=ALTSEQ)),
* Change '$'s to blanks so squeeze can remove them.
        IFTHEN=(WHEN=INIT,
          BUILD=(1,161,SQZ=(SHIFT=LEFT,PREBLANK=C'$'))),
* Replace X'FF's with blanks to get the blanks back.
* Note that blank padding at end of each record will be
* replaced with X'FF's (we can't avoid this).
        IFTHEN=(WHEN=INIT,
          BUILD=(1,161,TRAN=ALTSEQ)),
* Extract the bytes before the first X'FF' into the
* 160-byte %nn field (this will get the original bytes
* padded with blanks, not X'FF's).
        IFTHEN=(WHEN=INIT,
          PARSE=(%00=(ENDBEFR=X'FF',FIXLEN=160)),
* Put the %nn field into the output record.  It will
* have blanks in the right places.
          BUILD=(%00))
/*


This is what the data looks like at each stage with a '-' shown for each X'FF' to make it easier to understand and the record truncated where it doesn't matter:

After first WHEN=INIT with BUILD:

Code:

aaaa--bbbbb$$$$$$xxxxx---xx$$$$--------------------
bbb--bbbb$$$$$$$$$ccccc----cccccc$$----------------


After second WHEN=INIT with BUILD:

Code:

aaaa--bbbbbxxxxx---xx--------------------
bbb--bbbbccccc----cccccc----------------


After third WHEN=INIT with BUILD:

Code:

aaaa  bbbbbxxxxx   xx                    ----------
bbb  bbbbccccc    cccccc                -----------


After fourth WHEN=INIT with PARSE and BUILD:

Code:

aaaa  bbbbbxxxxx   xx
bbb  bbbbccccc    cccccc


For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTFs, see:

Use [URL] BBCode for External Links
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top