URGENT**** Need Help with Writing to File

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Locked
File

URGENT**** Need Help with Writing to File

Post by File » Tue Nov 12, 2002 9:44 pm

I need to generate a file that should be 80 bytes long.
The data at the end of each of the records are empty spaces.
I have declared:
data: begin of x_file occurs 0,
rec(80),
end of x_file.

then in my code I am in a loop moving different fields to build this record:

concatenate A B C D into x_file-rec.

** D above is defined as D(28) value space.

append x_file.
clear x_file.
transfer x_file to p_file.
refresh x_file.

The problem is I don't receive the file in 80 byte records they vary as to where the data ends in the record.

Can someone tell me what I'm doing wrong??

bktee22

Post by bktee22 » Tue Nov 12, 2002 11:25 pm

Try defining last field (D) 80 char, let the concatenate command handle the truncation.

Rich
Posts: 7116
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool
Contact:

Post by Rich » Wed Nov 13, 2002 3:57 am

You will need to place a carriage return at the end of your data record.

Code: Select all

data: begin of x_file occurs 0, 
                 rec(80),
                 cr type x, 
        end of x_file.

Constants: c_cr type x value 0D.
Concatenate A B C D into x_file-rec.
Move c_cr to x_file-cr.
...
....
Rich

ocvantol
Posts: 929
Joined: Tue Oct 22, 2002 3:19 am
Location: The Hague

Post by ocvantol » Wed Nov 13, 2002 4:38 am

As always, the answer can be found using F1.

len = 80
TRANSFER f TO dsn LENGTH len.

Locked