View previous topic :: View next topic |
Author |
Message |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Fri Mar 07, 2008 6:58 pm Post subject: Getting Cr at the end of the file |
|
|
Hi
I am getting a file from Unix into a mainframe dataset using FTP. Each record is getting a '.' at the end. When I open up the file in the hex mode, it shows 0D. Can someone please help me strip this character using the FTP utility itself.
Thanks in advance. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Mar 07, 2008 7:41 pm Post subject: |
|
|
varundb,
Did you get the file to unix from a windows machine? if so that explains as to why you had the extra '0d' at the end. In any case You can delete the x'0D' from unix using the tr command like
Code: |
tr -d '\r' <your unix input file with x'0d'> output.file
|
Then ftp the "output.file" to your mainframe.
Hope this helps... _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Sat Mar 08, 2008 10:33 am Post subject: |
|
|
Kolusu
Thanks for the quick reply. The problem I am facing is that I don't have admin rights on the Unix box. We get an encrypted file from a third party and the script on Unix box decrypts it from where I get it using FTP. Ideal solution would be if I can do some manipulation in the FTP job run at the mainframe to truncate these characters.
Thanks for your help |
|
Back to top |
|
 |
superk Advanced

Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Sat Mar 08, 2008 7:33 pm Post subject: |
|
|
I'd be curious to know what the files actually contain for both the end-of-line (EOL) and eond-of-file (EOF) values.
Anyway, I'm sure you could pass the file through a SORT after you receive it and truncate the last byte. |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Sun Mar 09, 2008 10:43 am Post subject: |
|
|
Superk
Thanks for the reply, but the problem is that the file I am talking about contains variable length records. |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Mon Mar 10, 2008 8:27 am Post subject: |
|
|
If there is no way of doing that using the FTP utility, can I remove the last character from a file with variable length records using DFSORT or some other utility?
Thanks for all your help.. |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Mon Mar 10, 2008 9:30 am Post subject: |
|
|
As an example-
The file looks like Code: |
01|123|12345.00.
02|134|43454456.00.
03|345|454543.00.
|
After stripping the last '.', the file should look like- Code: |
01|123|12345.00
02|134|43454456.00
03|3456|454543.00 |
|
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Mon Mar 10, 2008 10:52 am Post subject: |
|
|
Here's a DFSORT job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (VB)
//SORTOUT DD DSN=... output file (VB)
//SYSIN DD *
OPTION COPY
OUTFIL VLTRIM=X'0D'
/*
|
_________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Mon Mar 10, 2008 12:41 pm Post subject: |
|
|
Frank
Thanks a ton for the quick reply, but I guess my last reply was a little ambiguous.. my file is a fixed length file which can have variable length records, the above step won't work on that.. right?
Regards |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Mon Mar 10, 2008 2:05 pm Post subject: |
|
|
Right now I am using this card-
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(01,80,TRAN=ALTSEQ)
ALTSEQ CODE=(0D40)
/*
This is working as it is replacing the Cr with spaces. Is it the best possible solution? |
|
Back to top |
|
 |
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Mon Mar 10, 2008 3:12 pm Post subject: |
|
|
"...my file is a fixed length file which can have variable length records,..."
"Fixed length file" means (to me anyway) your file has the same number of records each time and is a fairly meaningless term. VB (variable, blocked) means a file consisting of variable length records and is blocked at more than 1 record per block. See manuals. _________________ ....Terry |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Mon Mar 10, 2008 3:39 pm Post subject: |
|
|
varundb,
You can use ALTSEQ code if you don't have negative packed decimal number. Negative packed decimal numbers have x'd' in the last nibble and you will be replacing it with a space.
Terry,
OP is having a fixed block file but the position of CR is variable. like shown below
Quote: |
aaaaaaaaaaaaaaaaaaaacr
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcr
cccccr
dddddddddddddddddcr
|
he needs to replace the CR to a space on each record _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
Terry_Heinze Supermod
Joined: 31 May 2004 Posts: 391 Topics: 4 Location: Richfield, MN, USA
|
Posted: Mon Mar 10, 2008 4:04 pm Post subject: |
|
|
"OP is having a fixed block file but the position of CR is variable."
This sentence seems self-contradictory to me. FB means fixed length records; VB means variable length records. OP: Could you verify that your records are of variable length? And not use the term (F)ixed (B)locked file? See definitions of FB and VB in the JCL Manual. _________________ ....Terry |
|
Back to top |
|
 |
varundb Beginner
Joined: 21 Apr 2007 Posts: 9 Topics: 1
|
Posted: Mon Mar 10, 2008 4:25 pm Post subject: |
|
|
Terry
Sorry for all the confusion. When I say the file is fixed length, that means it is defined as a FB file with length(let's say 80). But the records can be anywhere from 50 to 80 characters long(there is a delimiter in the file). So if for the first record, the amt is 10$, the record will be something like 01|123|10. and if for the second record, the amount is 100,000, then the record would be 02|122|100000.
The file length is defined to be the maximum length that can be.
As for Kolusu's question, the file will have the amounts as 9(3).9(2)(It will always be positive).
Thank you all for your help in this. |
|
Back to top |
|
 |
Frank Yaeger Sort Forum Moderator

Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
|
Posted: Mon Mar 10, 2008 4:26 pm Post subject: |
|
|
Quote: | Thanks a ton for the quick reply, but I guess my last reply was a little ambiguous.. my file is a fixed length file which can have variable length records, the above step won't work on that.. right |
You really should learn the correct terminology to avoid confusion.
A variable-length (VB) file can have records of different lengths.
A fixed-length (FB) file must have records of the same length.
I assumed from your description that your file is a VB file. VLTRIM=X'0D' will work for a VB file.
It sounds like what you really have is an FB file with a X'0D' to indicate the "end" of the data followed by blanks padded out to the fixed length of the record. VLTRIM=X'0D' will be ignored for an FB file.
As Kolusu points out, your ALTSEQ will work as long as you only have one X'0D' in each record. Otherwise, you'll replace X'0D' characters that you don't want to replace. _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort |
|
Back to top |
|
 |
|
|