View previous topic :: View next topic |
Author |
Message |
kseenu Beginner
Joined: 08 Jun 2004 Posts: 11 Topics: 5
|
Posted: Wed Sep 14, 2005 5:05 am Post subject: Replace CRLF characters to Space |
|
|
I have String of 455 chars. It may contain Carriage Return in between. Is there any way to check for availablity of Carriage return in a String and if Found, I have to replace the Carriage Return with spaces.
The hex value of CRLF is X'0D25'.
Thanks
Seenu |
|
Back to top |
|
|
Phantom Data Mgmt Moderator
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Wed Sep 14, 2005 5:41 am Post subject: |
|
|
Seenu,
There are several ways of replacing a Character or string.
1. Using Sort (ALTSEQ)
2. Using Rexx
3. Using COBOL,
4. Using File-Aid
5. Using Easytrieve.....
Which one do you prefer?
Thanks,
Phantom |
|
Back to top |
|
|
Phantom Data Mgmt Moderator
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Wed Sep 14, 2005 5:42 am Post subject: |
|
|
Whatever be the case, I need the LRECL, RECFM of your input file.
Thanks,
Phantom |
|
Back to top |
|
|
ANIL SARATHY Beginner
Joined: 30 Aug 2005 Posts: 88 Topics: 3 Location: Syracuse,New york
|
Posted: Thu Sep 15, 2005 1:22 am Post subject: |
|
|
For information only.
Using Sort (ALTSEQ) , we can change as many as 1 byte values , but not 2 consecutive bytes ( always).
hex representation:
F F F 4 2 0 0 2
1 2 3 0 5 D D 5 .
Here we need to change "0d25" values only. if in the input file "od" and "25" don't appear any where individualy ie separate from each other then ALTSEQ can be used. Other wise it will change OD and 25 , no matter whereever they are. It defeats the purpose of changing CLRF with spaces.
Other wise , we have to use X,2,CHANGE=(2,x"0d25",x"4040"),nomatch=(x,2) for all positions.
_________________ Anil Sarathy |
|
Back to top |
|
|
kseenu Beginner
Joined: 08 Jun 2004 Posts: 11 Topics: 5
|
Posted: Thu Sep 15, 2005 2:11 am Post subject: |
|
|
I am fetching the data from DB in a Cobol Program. Then I have to search for the CRLF value and replace them with spaces.
The LRECL is 3657 and RECFM is FB
thanks |
|
Back to top |
|
|
ANIL SARATHY Beginner
Joined: 30 Aug 2005 Posts: 88 Topics: 3 Location: Syracuse,New york
|
Posted: Thu Sep 15, 2005 3:34 am Post subject: |
|
|
try this
Code: |
//REPSORT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD input file
//SORTOUT DD output file
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,3657,TRAN=ALTSEQ)
ALTSEQ CODE=(0D40,2540)
/*
|
i didn't tried this
Code: |
//XXXXX EXEC PGM=FILEAID
//SYSPRINT DD SYSOUT=*
//DD01 DD input file
//DD01O DD SYSOUT=*
//SYSIN DD *
$$DD01 COPY REPLALL=(1,0,X'0D25',X'4040')
/*
|
_________________ Anil Sarathy |
|
Back to top |
|
|
Phantom Data Mgmt Moderator
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Thu Sep 15, 2005 3:40 am Post subject: |
|
|
Seenu,
If you are reading this file using a COBOL why not just use INSPECT..REPLACING ?
Code: |
INSPECT WS-SOURCE-DATA
REPLACING ALL X'0D40' BY SPACES
|
Hope this helps,
Thanks,
Phantom |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12372 Topics: 75 Location: San Jose
|
Posted: Thu Sep 15, 2005 7:48 am Post subject: |
|
|
Anil sarathy,
You need to use the BBCODEs to enable the proper format of the code.
put your code enclosed in between the bbcode and check it.
{code}
//REPSORT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD input file
//SORTOUT DD output file
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,3657,TRAN=ALTSEQ)
ALTSEQ CODE=(0D40,2540)
/*
{/code}
Now replace the { brackets with [ for {CODE} & {/CODE} .
Now this is how it looks like
Code: |
//REPSORT EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD input file
//SORTOUT DD output file
//SYSIN DD *
OPTION COPY
OUTREC FIELDS=(1,3657,TRAN=ALTSEQ)
ALTSEQ CODE=(0D40,2540)
/*
|
Hope this helps...
Cheers
kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
Mervyn Moderator
Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Thu Sep 15, 2005 3:42 pm Post subject: |
|
|
I'm with Phantom, only it's X'0D25', not X'0D40' _________________ The day you stop learning the dinosaur becomes extinct |
|
Back to top |
|
|
bauer Intermediate
Joined: 10 Oct 2003 Posts: 315 Topics: 49 Location: Germany
|
Posted: Fri Sep 16, 2005 5:59 am Post subject: |
|
|
Quote: |
I am fetching the data from DB in a Cobol Program. Then I have to search for the CRLF value and replace them with spaces.
|
kseenu,
if your database is DB2 try this:
SELECT
REPLACE(MYFILED, <CRLF> , <BLANKS> .......) AS MYFILED
FROM MYTABLE
WHERE ......
<CRLF> = X'0D25', <BLANKS> = X'4040'
regards,
bauer |
|
Back to top |
|
|
|
|