2008 Jan 15 3:48 PM
Greetings,
I'm creating an application that need to create a fixed length file on a UNIX system and need help. I have an internal table(s) which contain structures with fields of different lengths (type c) and so I have a routine that concatenates these fields into a single record to be sent to a file using the open dataset. This process is squeezing out all my spaces and so my fixed length file is lost. Can someone assist in creating a fixed length file from an internal table without using delimiters?
Thanks!
Greetings,
I'm creating an application that need to create a fixed length file on a UNIX system and need help. I have an internal table(s) which contain structures with fields of different lengths (type c) and so I have a routine that concatenates these fields into a single record to be sent to a file using the open dataset. This process is squeezing out all my spaces and so my fixed length file is lost. Can someone assist in creating a fixed length file from an internal table without using delimiters?
Thanks!
2008 Jan 15 4:02 PM
Joseph,
Please read the online help on CONCATENATE statement and you will find that it is designed to remove spaces.
If your internal table structure contains only text fields, then just don't concatenate individual fields. Just output the entire record to the file like below. Then you will get a file of fixed width.
TRANSFER itab_header TO dataset.
2008 Jan 15 4:11 PM
Something like this way
Data : begin of itab.
Field1(1) type c,
Field2(2) type c.,
Field3(3) type c,
Field4(4) type c.
Data : end of itab.
Data : begin of itab1 occurs 0.
Field(20) type c.
Data : end of itab1.
Loop at itab.
Move itab to itab1.
Append itab1.
Endloop.
Open dataset ........
Loop at itab1.
Transfer itab1 TO dataset.
Endloop.
a®
2008 Jan 15 7:12 PM
This seems work only if my table record has a value of some kind in the last field.
So to use your example if Field1 and Field4 has data my fixed lengths are preserved however if only Field1 has data and 2,3,4 are empty then record ends right after Field1.
Ideas?
2008 Jan 15 7:26 PM
ABAP statement TRANSFER has an addition LENGTH that can be used to specify the width of the line.
2008 Jan 15 7:50 PM
" May be placing a carriage return end of each records
" will solve your problem
class cl_abap_char_utilities definition load.
data : begin of itab,
field1(1) type c,
field2(2) type c,
field3(3) type c,
field4(4) type c,
crlf(2) type c value cl_abap_char_utilities=>cr_lf. "<<<See this line<<<
data : end of itab.
Data : begin of itab1 occurs 0.
Field(20) type c.
Data : end of itab1.
Loop at itab.
Move itab to itab1.
Append itab1.
Endloop.
Open dataset ........
Loop at itab1.
Transfer itab1 TO dataset.
Endloop.
a®
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |