View previous topic :: View next topic |
Author |
Message |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 2:44 pm Post subject: Issue with Variable length file |
|
|
Hi,
I have a file declared as below for a variable length file
FD TXN-FILE
LABEL RECORDS ARE STANDARD
RECORD IS VARYING FROM 1 TO 30000 CHARACTERS
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS V
DATA RECORD IS ELIG-MIG-REC.
01 ELIG-MIG-REC PIC X(30000).
My output varies from 1 to 30K. It can be any length between 1 to 30K.
Now my problem is I am getting spaces at the end of each record. What can I do to get the file with exact recrod length and I should not have any character after the length of the record that I put. Say if my data is of 10000 the reamaining should not have any character. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12381 Topics: 75 Location: San Jose
|
Posted: Tue Apr 24, 2007 2:52 pm Post subject: |
|
|
sriramkarumuri,
Check and see where you are initializing the ELIG-MIG-REC. If you don't initialize you will have low-values(x'00') at the end of every record.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 2:54 pm Post subject: |
|
|
I am intializing the variable as my variable is of alphanumeric I am getting spaces.
x'40'. But I dont want this as my file will be sent to other distributed platform which is creating issues over there.
I am thinking that can the record become a variable as the file declared as variable length file. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12381 Topics: 75 Location: San Jose
|
Posted: Tue Apr 24, 2007 3:01 pm Post subject: |
|
|
Quote: |
I am thinking that can the record become a variable as the file declared as variable length file.
|
I am totally confused. you defined a variable block file and it will be a variable block file. What do you want at end of record? Do you need a carriage return/line feed at the end of the record? Are you transferring this file to PC platform?
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 3:22 pm Post subject: |
|
|
Yes, I want to transfer to PC platform (Windows) thru FTP. I dont want any character at the end of the record.
lets say if my record contains data "1234" I dont want to send as "1234 " . |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Apr 24, 2007 3:28 pm Post subject: |
|
|
if you want variable length records, why have you not coded for it? what does your write logic look like? As far as I can see, you are writing 30K records each time. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 3:38 pm Post subject: |
|
|
problem is that record can be any length between 1 to 30K as I mentioned earlier. |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 3:43 pm Post subject: |
|
|
There are spaces HEX'40' at the end of every record. This contributes to size of file when its FTPd. |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 3:50 pm Post subject: |
|
|
Is there any additional parameters to pass while ftp that truncates the additional spaces at the end of record? |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Apr 24, 2007 3:53 pm Post subject: |
|
|
sorry, I was not very explicit with my answer. You are either- writing fixed length 30k record each time
- your calculation for the length of each output record is incorrect.
Quote: | FD TXN-FILE
LABEL RECORDS ARE STANDARD
RECORD IS VARYING FROM 1 TO 30000 CHARACTERS
BLOCK CONTAINS 0 RECORDS
RECORDING MODE IS V
DATA RECORD IS ELIG-MIG-REC.
01 ELIG-MIG-REC PIC X(30000). |
the above will only write records of 30k each to a variable blocked file. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 3:57 pm Post subject: |
|
|
By variable length I mean all the records in the flat file should be treated as variable length.
Eg Considering the records below in a 50 byte which is FTPed
XXXXXXXXXXXXXX (14 Bytes)
XXXXXXXXXXXXXXXXXXXX (20 Bytes)
XXXXXXXXXXXXXXXX (16 Bytes)
XXXXXXX
The first record should be sent as 14 bytes and not 50 bytes.
Is this possible ?
Note: I am doing FTP to Unix Server |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Apr 24, 2007 4:12 pm Post subject: |
|
|
you are not properly coding for variable length records.
you need either multiple 01 descriptions, or an ODO.
start here:
Variable length record definitions
ODO explanation _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12381 Topics: 75 Location: San Jose
|
Posted: Tue Apr 24, 2007 4:42 pm Post subject: |
|
|
sriramkarumuri,
you need a line feed character at the end of record. On UNIX it is (x"0A") character.
so all you need to do is that you if you are creating a 15 byte length then populate the length field as 16( 15 + 1 byte line feed) and move a x'0A' in pos 20 (4 byte rdw + 15 byte actual data + 1 byte line feed ).
similarly follow the same for all the records.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
sriramkarumuri Beginner
Joined: 07 Feb 2006 Posts: 28 Topics: 7
|
Posted: Tue Apr 24, 2007 5:41 pm Post subject: |
|
|
Thanks Kolusu,
I did that sending a line feed character at the end that creating a separate line between every two records. I have explicitly removed the linefeed according to the requirement. Below is my output how it looks like. Every record starts with SH and there is a newline for differnt type i.e., between PH,CO,SC,SE. This combination will repeat n no. of times under SH and I have explicitly removed line feed at the end of each record. Total SH,PH,CO,SC,SE is one record. Before writing into the file i am using string functions to strip the spaces.
As said by dick I can not declare mutiple 01 descriptions and also I can not have a new line character at the end and I should not send the spaces. Thinking that there should be an alternative way in FTP step to strip spaces at the end.
Problem happening immediatley after SE and next immediate SH
SH0000132
PH1xxxxxxxxx+0000000.00200
CO1.01fjsafkj;fjsafjsafkljsafsajkf;
CO1.02fdkl;dsafj;safj;fjs;afkljsafjkdsaf;
SC1.001safjsafklsafj;;saf
SC1.002sdfjsafkjs;af;klsaf
SE1.01ksafjdsaY2006-07-11
SE1.02sifdjsafY2006-05-18
SE1.03sfkl;jsafksafY2006-05-18
SH0000146306-050705437
PH1skfjsafksfj
.......................
total record length varies from 1 to 30K
Thanks,
Sriram |
|
Back to top |
|
 |
dbzTHEdinosauer Supermod
Joined: 20 Oct 2006 Posts: 1411 Topics: 26 Location: germany
|
Posted: Tue Apr 24, 2007 6:09 pm Post subject: |
|
|
Quote: | As said by dick I can not declare mutiple 01 descriptions |
actually, I said you should use multiple 01's or use an ODO.
I still fail to see how the pgm is creating records of any length other than 30k. _________________ Dick Brenholtz
American living in Varel, Germany |
|
Back to top |
|
 |
|
|